1001Ferramentas
🔄Converters

CSS to LESS Converter

Convert CSS stylesheets to LESS syntax, turning custom properties (--var) into @variables. Modernize your CSS and copy the ready-to-use code.

Turning CSS variables into LESS variables

LESS already accepts plain CSS, so migrating a stylesheet is rarely about rewriting rules. It is about the variables. A modern file full of --brand and var(--brand) compiles fine, and you end up maintaining two variable systems side by side in the same project. This page does the swap: paste the CSS and the same code comes back with @brand where the custom properties were.

It is a surgical find and replace, not a reformatter. Two rules apply: --name: value; becomes @name: value;, and var(--name) becomes @name. Braces, semicolons, comments and rule order pass through untouched, on purpose, because LESS is a superset of CSS and the file has to stay valid. That also keeps the two panes easy to diff line by line before you save anything.

Two things are left for you. The fallback form, such as var(--gap, 8px), is not matched and comes through unchanged, so pick a value yourself. And if the custom properties lived inside :root, they are converted right there, while a LESS variable declared inside a block only exists inside that block: move the @ declarations to the top of the file. A declaration missing its final semicolon is skipped too. Two text areas, no copy button, converting locally as you type.

Frequently asked questions

Does the output still work as plain CSS?
No. @brand is not browser syntax, so what you get is a .less file that has to be compiled before it ships.
What about variables I change at runtime?
Leave those alone. A LESS variable is resolved at compile time and disappears from the final file, so anything you swap with JavaScript for theming should stay a CSS custom property.
Can it output SCSS instead?
No, the prefix here is always the LESS @. SCSS would use $, and this converter does not produce that.

Related Tools