How to use it
This CSS to SCSS converter takes a plain stylesheet and nests consecutive rules that start with the same parent selector, so .menu li a ends up inside li inside .menu, and :hover becomes &:hover. Rules are never moved, which means the compiled result behaves exactly like your original CSS. The conversion runs in your browser, and minified input is fine.
How to convert CSS to SCSS
- Paste the CSS into the input box.
- Press "Run tool" or Ctrl + Enter to nest it.
- Review the nested output and note repeated values that deserve variables.
- Save the result to a
.scssfile in your project.
What the nesting looks like
Four rules for a menu, .menu{display:flex}, .menu li{list-style:none}, .menu li a{color:#333} and .menu li a:hover{color:#8f39e8}, become a single tree: a .menu block holding display: flex; and a nested li block, which holds list-style: none; and a nested a block, which in turn holds &:hover. Child combinators are kept as well: .card>img becomes > img inside .card. Indentation is two spaces and comments stay where they were.
When rules are grouped, and when they are not
- Grouped: rules that follow each other directly and begin with the same compound selector, such as
.card,.card imgand.card:hover. - Not grouped across other rules: in
.card,.btn,.card h3, the second.cardrule stays separate. - A parent appearing again after its children (
.a,.a b,.a) starts a new block. - Selector lists such as
.hero,.bannerare left as they are. - Media queries keep their position; rules inside them are nested among themselves.
- Compound classes and BEM names such as
.btn.is-activeor.card__titlecount as different selectors, so the tool does not produce&.is-activeor&__title.
Why only neighboring rules are nested
When two rules with the same specificity match the same element, the one written later wins. Gathering scattered .card .title rules into one block means moving some of them past other rules. If a rule like .box .title, with equal specificity, sits between them, a title inside both a card and a box could change color. The converter refuses to take that risk and only merges rules that already sit side by side. The output can look less nested than you expected, but it compiles to CSS with the same cascade as your source.
Finishing the job by hand
| Task | Why the tool leaves it to you |
|---|---|
Extract variables such as $brand: #8f39e8 | Only you know whether two identical colors mean the same thing |
| Create mixins for repeated media queries | Naming and grouping are design decisions |
Rewrite .card__title as &__title | Optional style choice that some teams avoid |
| Flatten very deep nesting | A commonly recommended limit is about three levels for readability |
| Split the file into partials | Depends on your project structure |
If the source is messy, run it through the CSS beautifier first so you can compare before and after more easily.
Good moments to convert
The converter earns its keep when you migrate a legacy stylesheet to an SCSS build and want a first draft in seconds, when you adopt component styles copied from a theme or from the browser's developer tools, and when you are about to split one large file into partials and need to see which rules belong together. In code review, nested output also makes it obvious which component a change touches.
Privacy and related tools
The conversion is JavaScript running in your tab; your stylesheet is not sent to the server, and the page only increments an anonymous usage counter. To check what your SCSS compiles to, use the SCSS to CSS converter, and find more utilities among the developer tools.