CSS to SCSS Converter
Turn plain CSS into tidy SCSS. Repeated selectors are nested, hover and other states become & rules, repeated colours become variables, and media queries keep their rules, ready to use as a starting point in a Sass project.
How to Convert CSS to SCSS
Quick answer: paste your CSS or open a file; the SCSS appears below. Copy it or download the .scss file.
-
1
Add your CSS
Paste it or open a file.
-
2
Choose options
Adjust the output on the right.
-
3
Check the SCSS
Errors show the line number.
-
4
Copy or download
Save it as .scss.
What You Get
What Is CSS?
CSS (Cascading Style Sheets) is the language that styles web pages: colours, fonts, spacing, layouts and animations. Every browser reads CSS directly. Plain CSS repeats selectors and values a lot in larger projects, which is why many developers write in a preprocessor such as SCSS or LESS and compile it to CSS.
What Is SCSS?
SCSS is the most popular syntax of the Sass style language. It looks like CSS but adds variables, nesting, mixins, functions and partials, so styles stay organised and consistent. Browsers cannot read SCSS directly; it must be compiled into plain CSS first.
Why Convert CSS to SCSS?
Moving an existing stylesheet into a Sass project by hand means retyping selectors and hunting for repeated colours. This converter does the tedious part in a second: related rules end up grouped together under their parent, and colours used more than once become variables you can change in one place.
How the Conversion Works
Each rule is split into its selector steps, such as nav, ul, li and a, and rules sharing the same start are grouped under one parent. States like :hover become &:hover inside their element, and child combinators such as > are kept. Rules with several comma-separated selectors are left as they are, and media queries are nested inside themselves. Comments, keyframes and other at-rules are kept.
Example
The sample navigation styles become one nav block with ul, li and a nested inside, the hover rule as &:hover, a .card block with .title nested, and the brand colour turned into a variable because it appears twice.
Tips
Grouping rules can change their order in the file. Where two rules set the same property on the same element, check that the intended one still comes last. Rename the generated variables, such as $color-1, to meaningful names like $brand.
Who Uses It?
Front-end developers, designers starting to use Sass, and teams modernising older stylesheets. Because the code never leaves the device, it is also safe for private and client projects.
Step by Step
Paste your CSS into the input box, drop a file onto it, or press Open File. The SCSS appears in the output box straight away and updates as you type, so you can fix errors and see the effect immediately. Adjust the options on the right. When it looks right, press Copy to put the result on your clipboard, or Download to save it as a .scss file. Press Sample to see a worked example first.
Using Your SCSS
Save the result as a .scss file in your project and compile it with your usual Sass setup. Rename the generated colour variables to meaningful names, move them into a separate variables file, and look for repeated groups of declarations that could become mixins. Compile once and compare the CSS with your original to confirm nothing changed.
About the Output
The output is ordinary SCSS that any Sass compiler accepts. Nesting follows the structure of your selectors, so a rule for nav ul li a ends up four levels deep unless single-child chains are joined. Joining keeps files flatter and easier to read. Deep nesting is harder to maintain, so a common rule of thumb is to stay within three or four levels.
Private, Free and Instant
The converter is free, with no sign-up and no limit beyond the 5 MB text size. Everything runs in your browser, so private source code, client projects and unreleased work are never uploaded or stored. It works on Windows, Mac, Linux and Chromebooks, and on tablets and phones.
CSS to SCSS: A Starting Point for Nested Styles
SCSS is CSS with extras such as nesting, variables and mixins. Every valid CSS file is already valid SCSS, so the conversion mainly reorganises rules into nested form.
Benefits
Selectors that share a parent are nested, which reduces repetition, and you can then replace repeated colours with variables. Do not nest too deeply: more than three levels makes styles hard to override.
For LESS, see LESS to CSS.
Frequently Asked Questions
Questions about CSS to SCSS