Format Code Now
/
ConvertLESS to SCSS Converter Next: LESS to Stylus Converter ›

LESS to SCSS Converter

CV-47

Rewrite LESS source as SCSS source: @variables become $variables, mixins become @mixin and @include, and the rest of the structure stays. A short list of review notes names what could not convert.

Runs in your browser. Nothing is uploaded.

LESS code

SCSS code

How to use it

  1. Paste your LESS into the input box, or open a .less file.
  2. Keep review notes on to get a comment block at the top listing anything that needs attention.
  3. Pick the indent and press Convert to SCSS.
  4. Copy the SCSS or download it as a .scss file.

What is rewritten

@color: red becomes $color: red. @{name} becomes #{$name}. ".box(@w; @h: 2px) {}" becomes "@mixin box($w, $h: 2px) {}", and ".box(1px);" becomes "@include box(1px);". &:extend(.a all) becomes @extend .a, and ~"text" becomes unquote("text"). Media query variables are converted too, with #{} when they stand alone.

What needs you

Guards such as "when (@a > 1)", detached rulesets, @plugin, @arguments, merge properties (prop+:) and inline JavaScript have no direct SCSS form. They are left unchanged or commented out and each one is listed with its line number. LESS functions such as fade() and percentage() are flagged, since Sass names them differently.

A LESS extend caveat

A LESS &:extend(.a) without the word all matches only the exact selector .a, but Sass @extend also matches .a inside other selectors such as .a:hover. The page adds a note when it sees that, because the CSS can differ. Compile both versions and compare when it matters.

Error messages and what to do

MessageWhat it meansFix
Missing } to close the block opened on line 3.A rule or at-rule was opened with { and never closed.Add the missing } at the end of the block that starts on the named line.
Unexpected } on line 5: there is no block to close.There is a } with no matching {.Delete the extra } or add the { it belongs to.
Unterminated /* comment starting on line 2.A /* comment has no closing */.Close the comment with */.
Unexpected { with no selector before it, on line 4.A { appears with nothing before it to name the rule.Add a selector before the { or remove it.

Questions people ask

How do I convert LESS to SCSS?

Paste the LESS and press Convert to SCSS. Variables, mixins, interpolation and extends are rewritten into SCSS syntax, and a comment block at the top lists any lines that need hand work. It converts the source, so mixins stay mixins.

Does it compile the LESS first?

No. Compiling would turn every variable and mixin into fixed CSS. This tool rewrites the source instead, so you keep your variables and mixins. If you only want the CSS, use the LESS to CSS compiler.

What happens to LESS guards and detached rulesets?

Guards on mixins are dropped with a note, because SCSS uses @if inside the mixin. Detached rulesets have no SCSS form and are kept as comments. Both show in the review notes with line numbers so you can rewrite them.

Are LESS mixin calls turned into @include?

Yes, a call such as .rounded(6px); becomes @include rounded(6px);. If the mixin is not defined in the pasted file, the converter still writes @include and adds a note to check that it exists.

Will the SCSS give the same CSS as my LESS?

For plain variables, nesting and mixins, yes, which is easy to check by compiling both. Differences can appear with LESS-only functions, lazy variable evaluation, extend without all and math rules, so read the notes at the top.

About this tool

Reads the LESS source and writes SCSS by rewriting its syntax, not by compiling it, so your variables and mixins stay. It converts @variables to $variables, @{name} interpolation to #{$name}, mixin definitions to @mixin, mixin calls to @include, &:extend() to @extend and ~"escapes" to unquote(). A LESS extend without the word all only matches the exact selector, while @extend also matches it inside other selectors, so such a line adds a review note. It cannot convert guards (when), detached rulesets, @plugin, @arguments, merge properties or JavaScript; those are left unchanged or commented out and listed in the review notes at the top. Check LESS functions such as fade() and percentage(), which Sass names differently. Always compile the result and compare it with the original CSS.

Format Code Now: free, no ads, no accounts. Your input stays in your browser.