LESS Formatter

Format and beautify LESS code.

Local Your input is processed locally in your browser. The first run loads the open-source Prettier library from this site; your input is not sent anywhere. Found a problem? Report an issue

What the LESS Formatter does

The LESS Formatter formats LESS with Prettier 3.3.3, an open-source code formatter, running in your browser. It supports LESS variables, mixins and nested rules.

LESS Formatter examples

The built-in sample

Input

@c:#333;.pad(@n){padding:@n}.card{.pad(8px);color:@c;&:hover{color:darken(@c,10%)}}

Output

@c: #333;
.pad(@n) {
  padding: @n;
}
.card {
  .pad(8px);
  color: @c;
  &:hover {
    color: darken(@c, 10%);
  }
}

This is the input that the Load sample button fills in.

Guards, line comments and operations

Input

// note
.a when (@mode=dark){color:#FFF}
@w:10px+5;

Output

// note
.a when (@mode=dark) {
  color: #fff;
}
@w: 10px+5;

The // comment is kept, the guarded rule is expanded and the colour is lower-cased. The expression 10px+5 is left as written: the formatter does not evaluate LESS.

Each output was produced by running this tool on the input above it.

How it works

The code is parsed with Prettier's less parser and printed again from its syntax tree, using Prettier's default options: lines up to 80 characters and two-space indentation. The result therefore does not depend on how the input was laid out. If the code cannot be parsed, the parser's message with its line and column is shown instead of output.

Details and limits

  • Mixin calls, guards (when), variables and nested rules are kept as LESS. Nothing is compiled to CSS and no expression is evaluated.
  • Both // and /* */ comments are preserved.
  • Hex colours are lower-cased and a space is put after each comma in function arguments.

Questions

Is my data uploaded when I use LESS Formatter?

No. The tool runs in your browser, so what you paste or open is processed on your own device and is not sent to a server.

What does LESS Formatter do?

The LESS Formatter formats LESS with Prettier 3.3.3, an open-source code formatter, running in your browser. It supports LESS variables, mixins and nested rules.

How does LESS Formatter work?

The code is parsed with Prettier's less parser and printed again from its syntax tree, using Prettier's default options: lines up to 80 characters and two-space indentation. The result therefore does not depend on how the input was laid out.

Are there any limits I should know about?

Mixin calls, guards (when), variables and nested rules are kept as LESS. Nothing is compiled to CSS and no expression is evaluated. Both // and /* */ comments are preserved.

Is there a size limit?

There is no fixed size limit. Everything happens on your device, so very large inputs depend on its memory and can take longer on a phone than on a computer.

Does it work on phones, and is it free?

Yes. It works in any current browser on Android phones, iPhones, tablets and computers. It is free and needs no account or sign-up.