CSS to SCSS Converter

Restructures plain CSS into nested SCSS by grouping consecutive rules that share a parent selector. Turns pseudo-classes into &:hover and never reorders rules.

The output will appear here.
Advertisement icyabmod — admin panel included: update your website yourself, no code

How CSS to SCSS Converter works

Restructures plain CSS into nested SCSS by grouping consecutive rules that share a parent selector. Turns pseudo-classes into &:hover and never reorders rules.

Input CSS
Output SCSS-ready code
Works done 1,322

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

  1. Paste the CSS into the input box.
  2. Press "Run tool" or Ctrl + Enter to nest it.
  3. Review the nested output and note repeated values that deserve variables.
  4. Save the result to a .scss file 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 img and .card:hover.
  • Not grouped across other rules: in .card, .btn, .card h3, the second .card rule stays separate.
  • A parent appearing again after its children (.a, .a b, .a) starts a new block.
  • Selector lists such as .hero,.banner are 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-active or .card__title count as different selectors, so the tool does not produce &.is-active or &__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

TaskWhy the tool leaves it to you
Extract variables such as $brand: #8f39e8Only you know whether two identical colors mean the same thing
Create mixins for repeated media queriesNaming and grouping are design decisions
Rewrite .card__title as &__titleOptional style choice that some teams avoid
Flatten very deep nestingA commonly recommended limit is about three levels for readability
Split the file into partialsDepends 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.

Advertisement Kelivo — a word game by icyabmod, on Google Play and the App Store

Frequently asked questions

Yes. SCSS is a superset of CSS, so any valid stylesheet is already valid SCSS and you could simply rename the file to .scss. Converting is about readability: nesting groups related rules so the structure of a component is visible at a glance. This tool handles the nesting; features such as variables, mixins and partials are worth adding by hand once you know the codebase.

Yes, in terms of behavior. The converter never reorders rules and only groups rules that are already adjacent, so after compiling, the same selectors appear in the same order with the same declarations. Specificity and the cascade are therefore unchanged. Formatting such as spacing and line breaks may differ depending on your compiler settings, which has no effect in the browser.

No. A tool cannot tell whether two identical color values represent the same design token or just happen to match, and merging them wrongly makes future changes risky. The converter only builds the nested structure. Use your editor's search to find repeated values, then decide which ones become variables with meaningful names, such as a brand color or a spacing scale.

Most likely they were not next to each other in the source, or they start with a different compound selector. Rules for the same parent separated by an unrelated rule stay apart to protect the cascade, comma-separated selector lists are left as they are, and compound or BEM-style classes such as .btn.is-active or .card__title count as different selectors. You can move rules together by hand if you have checked that it is safe.