CSS to SCSS Transformer
Transform plain CSS into clean SCSS with nested selectors, variables, and &-prefixed pseudo-classes
Paste flat CSS in, get nested SCSS out — selectors grouped under shared parents, repeated colors pulled into $variables, and pseudo-classes converted to & syntax. Turns a messy 500-line stylesheet into something a team can actually maintain.
Pick your max nesting depth, toggle auto-variables on or off, and hit Transform. And everything runs in your browser. Nothing gets uploaded.
How It Works
The parser breaks your CSS into individual rule blocks, then groups selectors that share a common ancestor. .nav .item and .nav .link both get nested inside .nav { }. Pseudo-classes like :hover become &:hover. If you turn on auto-variables, any hex, rgb, or hsl color that shows up three or more times gets extracted into a $variable at the top of the output.
Examples
Nesting a navigation component
You have flat CSS for a navbar with links, hover states, and an active class. The converter groups them under one parent.
.nav { display: flex; }
.nav a { color: #333; }
.nav a:hover { color: #0066cc; }
.nav .active { font-weight: 700; }
.nav {
display: flex;
a {
color: #333;
&:hover {
color: #0066cc;
}
}
.active {
font-weight: 700;
}
}
Extracting repeated colors into variables
Same blue showing up everywhere? Turn on auto-variables and the converter pulls it out for you.
.btn { background: #2563eb; }
.link { color: #2563eb; }
.badge { border-color: #2563eb; }
.heading { color: #1e293b; }
$color-1: #2563eb;
.btn { background: $color-1; }
.link { color: $color-1; }
.badge { border-color: $color-1; }
.heading { color: #1e293b; }
Media queries with nested rules inside
The converter keeps your @media blocks intact and still nests the selectors within them. Handy for responsive layouts that share parent selectors.
@media (max-width: 768px) {
.card { padding: 1rem; }
.card .title { font-size: 1rem; }
.card .body { font-size: 0.875rem; }
}
@media (max-width: 768px) {
.card {
padding: 1rem;
.title {
font-size: 1rem;
}
.body {
font-size: 0.875rem;
}
}
}
Who Uses This
Migrating legacy CSS codebases to SCSS without rewriting every file from scratch.
Turning exported CSS from design tools into organized SCSS with proper nesting.
Learning how SCSS nesting and variables work by seeing their existing CSS converted side-by-side.
Standardizing a project on SCSS when half the stylesheets are still plain CSS.
Common Mistakes
Deep nesting (5+ levels) produces SCSS that compiles into bloated, overly specific selectors. Keep it at 3 or 4 max. If the output looks like a Russian nesting doll, lower the depth setting.
The SCSS this tool generates should compile back to the exact same CSS you started with. It is a structural reorganization, not a rewrite. If the compiled output looks different, check for specificity changes caused by nesting order.
SCSS files need a .scss extension, not .css. Your build tool won't process the nesting or variables if the file is still named styles.css. Rename it before importing.
Technical Details
- Processing: 100% client-side — nothing leaves your browser
- Browser Support: Chrome, Firefox, Safari, Edge
- Variable Detection: Hex, RGB, and HSL colors repeated 3+ times
- Max Nesting: Configurable from 1 to 10 levels (default 4)
- Output: Copy to clipboard or download as
.scssfile
Frequently Asked Questions
What's the difference between SCSS and Sass?
SCSS uses curly braces and semicolons, just like regular CSS. Sass uses indentation instead — no braces, no semicolons. Most teams pick SCSS because any valid CSS file is already valid SCSS, so migration is painless. This tool outputs SCSS specifically.
Will the converted SCSS compile back to my original CSS?
Yes. The conversion is purely structural. Selectors get nested and repeated colors become variables, but the compiled output should match your original CSS rule for rule. If something looks off, check the nesting depth — very deep nesting can sometimes reorder specificity.
Does this handle @media queries and @keyframes?
Media queries are preserved as-is, and the rules inside them still get nested. Keyframe blocks pass through untouched since they don't benefit from selector nesting.
Is my CSS sent to a server?
No. Everything happens in JavaScript right in your browser tab. Disconnect from the internet and it still works. Your code is never uploaded, logged, or stored anywhere.
Can I convert SCSS back to plain CSS?
That's a different process — you'd need an SCSS compiler like Dart Sass or the sass npm package. This tool goes one direction: flat CSS in, nested SCSS out. For the reverse, check out a dedicated SCSS compiler tool.