You inherit a project with a styles/ folder full of .scss files, or you copy a snippet from a design system that uses $variables and @include, and the browser refuses to understand any of it. Browsers only read CSS. SCSS is a language that has to be compiled into CSS first, and knowing what the compiler does with each feature makes the output far less mysterious.
This guide explains what SCSS is, how it relates to the older indented Sass syntax, what each common feature turns into after compilation, and how to compile a file quickly in a browser or from the command line.
SCSS, Sass and CSS: the short version
Sass is a stylesheet language and the name of its compiler. It has two syntaxes:
- SCSS (
.scss, "Sassy CSS") uses braces and semicolons. Every valid CSS file is also valid SCSS, which is why most teams choose it. - Indented syntax (
.sass) uses indentation instead of braces and drops semicolons. It is more compact but less common today.
Both compile to the same CSS. The reference compiler is Dart Sass. The older LibSass and Ruby Sass implementations are deprecated, so tutorials that mention node-sass describe tooling you should migrate away from.
Modern CSS has adopted some ideas that made Sass popular, notably custom properties (--brand: #1d4ed8) and native nesting in current browsers. Sass still adds compile-time features that CSS lacks, such as mixins, loops, maps and module imports that combine partial files into one stylesheet.
What each SCSS feature becomes
Here is a small component written in SCSS:
$brand: #1d4ed8;
$brand-dark: #1e40af;
$radius: 6px;
@mixin focus-ring($color) {
outline: 2px solid $color;
outline-offset: 2px;
}
.button {
border-radius: $radius;
background: $brand;
&:hover { background: $brand-dark; }
&:focus-visible { @include focus-ring($brand); }
&--ghost {
background: transparent;
color: $brand;
}
}
And the CSS that Dart Sass produces with the expanded style:
.button {
border-radius: 6px;
background: #1d4ed8;
}
.button:hover {
background: #1e40af;
}
.button:focus-visible {
outline: 2px solid #1d4ed8;
outline-offset: 2px;
}
.button--ghost {
background: transparent;
color: #1d4ed8;
}
Notice what happened:
| SCSS feature | What the compiler does |
|---|---|
$variable |
Replaced by its value; the variable itself does not exist in the CSS |
Nesting and & |
Flattened into full selectors (&--ghost becomes .button--ghost) |
@mixin / @include |
The mixin's declarations are copied into each place it is included |
%placeholder + @extend |
Selectors are grouped so the shared rules appear once |
@each, @for, @if |
Run at compile time to generate repeated rules |
@use "sass:math" |
Loads a built-in module of functions such as math.div() |
Because everything is resolved at compile time, a Sass variable cannot change in the browser. If you need values that switch at runtime (a dark theme, user settings), output CSS custom properties from your Sass.
Compile SCSS in your browser
The SCSS to CSS Compiler runs the official Dart Sass compiler inside your browser, so your stylesheet is not uploaded.
- Open SCSS to CSS Compiler and choose Input syntax: SCSS (.scss) or Indented Sass (.sass).
- Paste your code into the input box, use Open file for a
.scssor.sassfile, or click Load sample to see variables, mixins,@extendand@eachin action. - Pick Output style: Expanded (readable) for reviewing, Compressed (minified) for production.
- Read the Compiled CSS as you type. If the compiler stops, the error shows the message with the line and column.
- Check the Compiler warnings box, which lists deprecation notices and
@debugoutput. - Copy the CSS or Download it as a
.cssfile.
One limitation matters: the browser tool cannot read other files from your disk, so @use "partials/variables" fails with "Can't find stylesheet to import". Built-in modules such as sass:math, sass:color and sass:map work. For a multi-file project, paste the partial's contents inline or compile locally.
Compile SCSS on your machine
For real projects, compile as part of your build. The standalone sass package on npm provides the Dart Sass command line:
# One file, readable output
npx sass styles/main.scss dist/main.css
# Minified, without a source map
npx sass --style=compressed --no-source-map styles/main.scss dist/main.css
# Recompile on every save
npx sass --watch styles:dist
Most front-end build tools (Vite, webpack with sass-loader, Next.js, Angular CLI) compile .scss imports automatically once the sass package is installed in the project, so you rarely run the CLI by hand there. Code editors also offer extensions that compile on save.
The browser tool is best for quick jobs: checking what a mixin outputs, converting a snippet for a site builder that only accepts CSS, or debugging a single error without setting up a project.
Pitfalls and troubleshooting
"Undefined variable" or "Undefined mixin"
The variable or mixin lives in another file that was not loaded, or it is defined below the line that uses it. Sass reads top to bottom, so move definitions above their first use and paste any partials inline when compiling in the browser.
Deprecation warnings about @import and global functions
Dart Sass is phasing out @import in favour of @use and @forward, and global colour functions such as darken() in favour of module functions like color.adjust() or color.scale(). The code still compiles today, but plan the migration; the warnings name the line to change.
Division with a slash
In older code, $width / 2 meant division. Modern Dart Sass treats / as a separator in many contexts. Use math.div($width, 2) after @use "sass:math";.
The output is larger than expected
Mixins copy their contents every time they are included, and deep nesting creates long selectors. If the compiled file is heavy, prefer @extend with placeholders for shared blocks, keep nesting shallow, and minify for production. The CSS Minifier can shrink any CSS file, and the guide on minifying CSS without breaking styles covers what is safe to remove.
Reading compressed output
If you only have the minified CSS, the CSS Formatter re-indents it so you can compare it with your source.
Frequently asked questions
Can browsers read SCSS directly?
No. Browsers understand only CSS, so SCSS must be compiled first, either during your build or with a tool like the SCSS to CSS Compiler.
Is SCSS the same as Sass?
SCSS is one of the two syntaxes of the Sass language; the other is the indented .sass syntax. Both compile to the same CSS with the same compiler.
Do I still need Sass now that CSS has nesting and variables?
Not always. Small projects can often use native nesting and custom properties. Sass remains useful for mixins, loops, maps and splitting code into modules that compile into one file.
Why does my @use of a partial fail in the online compiler?
The compiler runs in your browser and cannot open files from your project. Paste the partial's contents above your code, or compile locally with the sass CLI.
Does the compiler convert CSS back to SCSS?
No. It compiles SCSS or indented Sass into CSS only. Because plain CSS is already valid SCSS, you can rename a .css file to .scss and start adding Sass features gradually.