CSS to SCSS Converter
Adapts CSS to SCSS preserving rules and turning CSS custom properties into SCSS variables when detected.
Swap custom properties for Sass variables
The part nobody mentions about migrating CSS to SCSS: there is barely a migration. Every valid CSS file is already valid SCSS, so renaming the extension is enough for the build to work. The real work is something else, and it is tedious: going through the file swapping custom properties, the double hyphen ones, for Sass dollar variables. That is precisely what this tool does, and all it does.
Two text substitutions, nothing more. A declaration starting with two hyphens followed by a colon and a value becomes the same line with a dollar sign, and every var call wrapping a custom property becomes the dollar reference. Everything else passes through untouched: selectors, media queries, comments. Two known catches: a var call with a fallback after the comma is not recognised and stays as is, and a declaration needs its closing semicolon to be detected.
What breaks the build later is scope. Your custom properties most likely live inside the root block; once they turn into dollar variables they are still in there, and a Sass variable declared inside a block only exists inside that block. Move the declarations to the top of the file or into a variables partial after converting. And do not convert what you change at runtime: class based themes, values that shift in a media query. Dollar dies at build time, double hyphen lives in the browser.
Frequently asked questions
Does it nest my selectors?
Do I actually need to convert CSS to SCSS?
What about var calls with a fallback value?
Related Tools
SCSS to CSS Converter
Strips simple SCSS features (variable declarations and // comments) producing an approximate CSS for inspection.
LESS to CSS Converter
Strips LESS @variables and // comments producing approximate CSS suitable for visual checking.
Stylus to CSS Converter
Explains converting Stylus templates (optional braces/colons) into standard CSS with examples.
SASS to CSS Converter
Explains the differences between indented SASS (.sass) syntax and CSS with side-by-side examples.
CSS to LESS Converter
Convert CSS stylesheets to LESS syntax, turning custom properties (--var) into @variables. Modernize your CSS and copy the ready-to-use code.
CSS to SASS Converter
Convert plain CSS to the indented SASS syntax, without braces or semicolons. Paste your CSS and copy the SASS to modernize your project styling.