A LESS beautifier makes nested rules, variables, and mixin calls easier to scan by applying consistent whitespace and indentation. This tool can also produce a compact version of the same LESS source for cases where preserving preprocessor syntax matters.
This is a formatter, not a LESS compiler. Beautify uses the CSS formatter from js-beautify, while Minify uses ParseCode's own syntax-preserving whitespace and comment helper. Neither mode resolves variables, executes mixins, calculates functions, expands nesting, or emits compiled CSS.
How to Use the LESS Beautifier and Minifier
Choose a readable layout or a compact LESS source representation.
- Select Beautify or Minify from the Action control.
- In Beautify mode, choose 2 spaces, 4 spaces, or Tab from Indent.
- Paste or edit LESS in Source code; the Output updates after a short pause.
- Check the status for the source and output byte counts; Minify also reports the calculated percentage reduction.
- Select Copy to copy Output.
- Select Use output as input when you want to continue editing or run the other mode on the current result.
What LESS Formatting Changes
LESS extends CSS with features such as variables, nesting, mixins, operations, and functions. Formatting changes how the source is laid out, not what those constructs are intended to mean. A compact rule can become easier to review:
@brand: #1d4ed8;
.button(@color: @brand) {
background: @color;
&:hover {
color: white;
}
}
The Beautify mode passes LESS source to js-beautify's CSS formatter with the selected indentation. It does not use the official Less.js parser. Common CSS-like structures and nesting can format well, but successful output is not proof that a LESS compiler accepts the source or that every newer or unusual LESS construct has been interpreted as intended.
Formatting also keeps at most two existing blank-line runs according to the configured formatter behavior and does not force a newline at the end. If a repository enforces different layout through a linter or formatter configuration, treat this output as a convenient draft rather than a replacement for the project's checks.
For ordinary CSS rather than preprocessor source, use the CSS beautifier. For Sass syntax, use the SCSS beautifier.
What LESS Minification Does and Does Not Do
Minify removes ordinary block comments, // line comments, repeated whitespace, and optional spaces around a limited set of punctuation. It also removes a semicolon immediately before }. Strings, url(...) contents, and comments beginning with /*! are temporarily protected so the cleanup does not alter their contents.
The minifier preserves LESS syntax instead of compiling it. It does not resolve @variables, inline imported files, evaluate darken(), merge selectors, remove unused rules, or optimize equivalent values. It is therefore different from running Less.js and then applying a CSS optimizer such as CSSO.
Because the helper is a lightweight scanner rather than a full grammar parser, check compact output when the source uses unusual constructs. In particular, it recognizes quoted strings and a simple url(...) form, but it is not a semantic validator. The reported byte reduction compares browser Blob sizes for the input and output; it is not a prediction of gzip or Brotli transfer size.
Minification disables the Indent control because compact output does not use the selected indentation. If deployment requires compiled CSS, run a real LESS compiler in the build pipeline and test the resulting stylesheet. This page deliberately leaves preprocessor directives intact.
Comments, Strings, and Common Formatting Mistakes
LESS accepts both CSS-style block comments and JavaScript-style line comments. In Minify mode, ordinary /* ... */ and // ... comments are removed. A block comment starting with /*! is retained, which is useful for license or attribution notices that must remain in a compact source file.
Comment-like text inside a quoted string is preserved. The helper also protects text inside url(...) so a data URI or path containing punctuation is not processed as a comment. That protection does not validate whether the URL or string is legal LESS.
Do not use visual formatting as a syntax check. An unmatched brace, invalid variable expression, or unsupported mixin call may still produce formatted text because the beautifier is arranging tokens rather than compiling the program. Use the official compiler and the project's automated tests to catch semantic and syntax failures.
Avoid mixing a large formatting rewrite with an unrelated behavior change. Reformatting an entire stylesheet can obscure the selector or declaration that actually changed. Apply the formatter in a dedicated change, then inspect a text diff before committing the result.
Privacy and Security When Formatting Stylesheets
Formatting and compacting happen in the browser. The page does not send the LESS source to a formatting API, although js-beautify is loaded as the formatter code when needed. This local workflow is useful for proprietary styles, but clipboard history, browser extensions, and screenshots remain separate exposure paths.
LESS files can reveal internal asset paths, unreleased design tokens, hostnames, or comments containing operational details. Remove secrets and confidential values before sharing a formatted result. Stylesheets should not contain credentials in the first place, even when the page that processes them is local.
Minification is not sanitization. It does not make untrusted CSS or LESS safe to compile or serve, and it does not inspect imported resources. Review inputs, restrict build-time imports as appropriate, and apply the security controls of the environment that ultimately compiles and publishes the stylesheet.
Frequently Asked Questions
Does this tool compile LESS into CSS?
No. Beautify rearranges LESS source with js-beautify's CSS formatter, and Minify removes comments and whitespace while retaining LESS syntax. Use Less.js or another compatible LESS compiler when you need browser-ready CSS.
Which comments does Minify preserve?
It preserves block comments that begin with /*!. Ordinary /* ... */ comments and // line comments are removed. Comment markers inside protected quoted strings or url(...) contents are kept as part of those values.
Does Beautify validate LESS syntax?
No. It can produce readable output from text that a LESS compiler later rejects. Compilation and project tests are the appropriate checks for valid variables, mixins, functions, imports, and nesting.
Why is Indent disabled in Minify mode?
Minified output removes optional layout whitespace, so a two-space, four-space, or tab indentation choice would have no useful effect. Switch back to Beautify to apply an indentation style.
Is my LESS source uploaded?
The formatting operation runs in the browser and does not submit the source to a conversion endpoint. You should still avoid placing secrets in stylesheets and consider other local exposure paths such as extensions and clipboard managers.
References: Less.js documentation: Features · js-beautify documentation.