CSS to SCSS Converter
CV-43Every valid CSS file is already valid SCSS. This tool adds the useful part: it nests rules that belong together, writes one selector per line and uses the indent you choose.
Runs in your browser. Nothing is uploaded.
CSS code
SCSS code
How to use it
- Paste CSS into the input box, or open a .css file.
- Keep the nesting option on for nested SCSS, or off to keep the rules flat.
- Choose the indent and press Convert to SCSS.
- Copy the SCSS or download it as a .scss file.
Nesting with the parent selector
Neighbouring rules are merged when one selector begins with the other. ".btn" then ".btn:hover" gives "&:hover" inside .btn, and ".btn" then ".btn .icon" gives ".icon". The & symbol is used for pseudo-classes, pseudo-elements, attributes and compound classes, so the compiled output is identical to what you pasted.
Rules it leaves alone
Selector lists with commas, rules separated from their parent by another rule, and anything inside at-rules other than the nesting within them are not rearranged across boundaries. @media blocks are processed on their own contents. CSS custom properties, url() data and strings are copied byte for byte.
After converting
SCSS adds variables, mixins and functions that CSS cannot hold, but this tool does not guess them for you. Pull repeated values into $variables by hand. To prove nothing moved, compile the result with the SCSS to CSS tool and compare it with your original.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
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 SCSS?
Paste the CSS and press Convert to SCSS. Since SCSS is a superset of CSS, the file is valid as it stands. The nesting option then regroups neighbouring rules so you can start using SCSS features straight away.
Is CSS valid SCSS?
Yes, any valid stylesheet is valid SCSS, which is why this conversion is safe. The difference is what you can add afterwards: variables, nesting, mixins, functions and partials. This page handles the nesting part.
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 were some of my rules not nested?
Nesting only happens for rules that directly follow their parent and have a single selector. If another rule sits between them, or the selector has a comma, moving it would change the order the browser applies rules in, so it stays where it is.
Does it convert CSS custom properties to SCSS variables?
No. Custom properties such as --brand are copied unchanged because they work at run time in the browser, while SCSS variables disappear at compile time. They are different tools, so converting one into the other would change behaviour.
About this tool
Valid CSS is already valid SCSS, so this tool does the part that helps: it rewrites the file in SCSS syntax 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.