Sass to Stylus Converter
CV-52Rewrite indented Sass as Stylus. Both use indentation, so nesting stays; variables become $name = value and mixins become name(args) definitions and calls.
Runs in your browser. Nothing is uploaded.
Sass code
Stylus code
How to use it
- Paste your indented Sass into the input box, or open a .sass file.
- Keep review notes on to list items that did not convert.
- Pick the indent and press Convert to Stylus.
- Copy the Stylus or download it as a .styl file.
What converts
$gap: 8px becomes $gap = 8px, and $x: 1 !default becomes $x ?= 1. "=box($w, $h: 2px)" or "@mixin box(...)" becomes "box($w, $h = 2px)", and "+box(1px)" becomes "box(1px)". Interpolation #{$x} becomes {$x}. Nesting, & and @media are kept, and // comments stay, including at the end of a line.
What is commented out
@if, @each, @for, @function, @use, maps, %placeholders and nested properties differ too much from Stylus. Each is kept as a // comment and listed with its line number in the notes. An @include with a content block is flagged as well. Indentation errors in the input stop the conversion with a line number.
Not compiled here
The Stylus is written by this page's own converter and is not run through the Stylus compiler, so test it in your build. Compare the CSS it gives with the Sass to CSS result for your original file to catch any differences, especially around operators, colors and anything listed in the notes.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
Inconsistent indentation on line 3. | A line is indented by an amount that does not match its siblings or any level above it. | Indent every child of a rule by the same number of spaces. |
Line 4 mixes tabs and spaces in its indentation. | One line starts with both tabs and spaces. | Use only spaces or only tabs for indentation. |
Questions people ask
How do I convert Sass to Stylus?
Paste the indented Sass and press Convert to Stylus. Because both syntaxes use indentation, nesting stays as it is while variables and mixins are rewritten into Stylus form.
How is a Sass mixin written in Stylus?
"=box($w)" or "@mixin box($w)" becomes "box($w)" with its declarations indented below, and "+box(1px)" becomes "box(1px)". A mixin with no parameters is written box() so Stylus treats it as a call.
What does !default become?
In Stylus the conditional assignment is ?=, so "$x: 1 !default" is written "$x ?= 1". It sets the value only when the variable has none yet.
Which Sass features are not converted?
Control flow (@if, @each, @for, @while), functions, @use, maps, placeholders and nested properties are kept as comments with a note. Stylus writes these differently, so they are for you to port.
Is the output checked by the Stylus compiler?
No. The Stylus compiler is not part of this page. Run the Stylus through your own build, then compare the CSS it produces with what the Sass to CSS tool gives for your original file.
About this tool
Parses the indented Sass, then writes Stylus from the same tree: $name: value becomes $name = value, mixins and includes become name(args) definitions and calls, #{} becomes {}, and the indentation is kept. @if, @each, @for, @function, maps and @content have no close Stylus form and are commented out with a note at the top. The output is not run through the Stylus compiler on this page, so test it before you rely on it.