About the CSS to SCSS
Rules like ".card .title" and ".card:hover" are grouped under ".card { }" with "&" for pseudo-classes, so the output looks like hand-written SCSS. Optionally, colors used more than once are pulled out into variables at the top.
SCSS, the most popular syntax of the Sass preprocessor, lets you nest selectors, use variables and organise styles into partials. Many teams adopt it on projects that started with plain CSS, and rewriting long stylesheets by hand is tedious. This converter does the repetitive first step: it groups related selectors under their parent so the result reads like hand-written SCSS.
Rules such as .card .title and .card:hover are nested under .card, using & for pseudo-classes and modifiers. Selectors that contain commas are kept as separate rules, so nothing ends up matching different elements than before. An option extracts colours used more than once into $variables at the top of the file, a common first step towards a design system.
How to use the CSS to SCSS
- 1Paste plain CSS.
- 2Choose whether to extract repeated colors into variables.
- 3Copy the SCSS.
Key features
- Automatic nesting of descendant selectors.
- & for pseudo-classes and modifiers.
- Optional colour variables for repeated colours.
- Comma selectors kept safe.
- Valid SCSS output.
Practical uses
- Migrating a legacy CSS project to Sass.
- Making long stylesheets easier to navigate.
- Extracting a colour palette from existing CSS.
- Learning SCSS nesting by example.
- Organising styles from a single large file into a nested structure before splitting into partials.
Example
The rules .nav { display: flex } .nav a { color: #f97316 } .nav a:hover { color: #c2410c } become one .nav block containing a nested a block, which contains &:hover. With colour variables on, repeated colours appear as $color-1 and similar at the top.
Tips and common mistakes
- Avoid nesting more than three levels deep; deep nesting creates overly specific selectors.
- Rename generated variables to meaningful names such as $brand-orange.
- Compile the SCSS and compare the CSS output with the original to confirm nothing changed.
- Convert one file at a time and compare its compiled output with the original before moving on.
Limitations
- Comments inside rules are removed.
- Mixins, functions and partials are not created automatically.
Privacy
Conversion happens in your browser.
Frequently asked questions
Is the output valid SCSS?
Yes. Plain CSS is already valid SCSS; nesting only makes it shorter and clearer.
Are comments kept?
Comments inside rules are removed during conversion. Keep a copy of the original if you need them.
What about complex selectors with commas?
Selectors with commas are kept as their own rule to avoid changing what they match.
Will the compiled CSS be identical?
It should match selector for selector, though the order of some rules may change when they are grouped.
Can I convert SCSS back to CSS?
Yes, by compiling it with Sass. This tool works in the CSS to SCSS direction only.