Format Code Now
/
ConvertCSS to Sass Converter Next: CSS to SCSS Converter ›

CSS to Sass Converter

CV-42

Turn CSS into the indented Sass syntax: no braces, no semicolons, nesting by indentation. An optional step also nests rules that share a parent selector.

Runs in your browser. Nothing is uploaded.

CSS code

Sass code

How to use it

  1. Paste CSS into the input box, or open a .css file.
  2. Leave nesting on for a compact Sass file, or turn it off.
  3. Pick the indent and press Convert to Sass.
  4. Copy the result or download it as a .sass file.

What the output looks like

Each rule becomes a selector line with its declarations indented beneath it. "color: red;" becomes "color: red". At-rules such as @media and @font-face keep their names and wrap their content by indentation. Selector lists are written one per line, with a trailing comma on all but the last.

Nesting and empty rules

With nesting on, ".card:hover" after ".card" becomes "&:hover" under it, and ".card .title" becomes ".title". Rules with an empty body are dropped, because indented Sass has no way to write one. Comments stay, and a comment at the end of a line stays there.

Check the indentation

Pick 2 spaces, 4 spaces or a tab and keep it for the whole file, since the Sass parser rejects inconsistent indents. Compile the result with the Sass to CSS tool to confirm it matches your original. If you would rather keep braces, the CSS to SCSS converter makes the same nesting with SCSS syntax.

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 */.

Questions people ask

How do I convert CSS to Sass?

Paste your CSS and press Convert to Sass. Braces and semicolons are removed and nesting is shown with indentation. The result is the indented Sass syntax, usually saved with a .sass extension.

Is the output SCSS or Sass?

Sass, the indented syntax. It has no braces or semicolons. If you want the brace-based syntax, use the CSS to SCSS converter, which keeps CSS punctuation.

What does the nesting option do?

When a rule directly follows a rule whose selector it starts with, it is moved inside it. ".card .title" after ".card" becomes ".title" inside ".card", and ".card:hover" becomes "&:hover". Only neighbouring rules with single selectors are merged, so the compiled CSS keeps the same order.

Why is an empty rule missing from the output?

Indented Sass cannot represent a rule with no declarations, since a selector line with nothing under it is not a block. An empty rule produces no CSS anyway, so dropping it does not change the compiled result.

Will the Sass compile to the same CSS?

Yes for the structure: declarations, selectors and at-rules are preserved, and only adjacent related rules are nested, so the order is unchanged. Compile it with the Sass to CSS tool to see for yourself.

About this tool

Valid CSS is already valid Sass, so this tool does the part that helps: it rewrites the file in Sass syntax (indentation instead of braces, no semicolons) and, if you leave the nesting option on, nests a rule under the rule before it when its selector starts with that rule's selector, for example .card .title after .card, or .card:hover written as &:hover. Only neighbouring rules are merged and only single selectors without commas, so the compiled CSS keeps the same order. Rules separated by other rules are left flat. It does not invent variables or mixins. Selector lists are split one per line, and a // comment inside a declaration is dropped.

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