CSS to Stylus Converter
CV-44Write your CSS in Stylus form: indentation instead of braces and no semicolons, with an option to nest rules that share a parent selector.
Runs in your browser. Nothing is uploaded.
CSS code
Stylus code
How to use it
- Paste CSS into the input box, or open a .css file.
- Turn on nesting if you want related rules grouped.
- Choose the indent and press Convert to Stylus.
- Copy the Stylus or download it as a .styl file.
What the converter writes
Each rule becomes an indented block, declarations lose their semicolons, and braces disappear. The colon after a property name is kept, which Stylus allows. At-rules like @media and @font-face keep their names. Selector lists go one per line, and comments are kept in place.
Nesting
If a rule directly follows its parent and starts with its selector, it is nested: ".menu a" after ".menu" becomes "a" inside it, and ".menu:hover" becomes "&:hover". Rules separated by something else stay flat so the cascade order is unchanged. Rules with an empty body are dropped, since Stylus has nothing to show for them.
Not compiled here
The result is produced by this page's own converter and is not run through the Stylus compiler, so try it in your build before relying on it. No variables are created: Stylus variables, mixins and functions are things you add yourself after converting.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
Missing } to close the block opened on line 3. | A rule or at-rule was opened with { and never closed. | Add the missing } at the end of the block that starts on the named line. |
Unexpected } on line 5: there is no block to close. | There is a } with no matching {. | Delete the extra } or add the { it belongs to. |
Unterminated /* comment starting on line 2. | A /* comment has no closing */. | Close the comment with */. |
Questions people ask
How do I convert CSS to Stylus?
Paste the CSS and press Convert to Stylus. The output is indentation-based, with no braces or semicolons, and related rules can be nested. Save it as a .styl file and run it through the Stylus compiler.
Does Stylus need colons and semicolons?
No, Stylus makes colons, semicolons and braces optional. This converter drops braces and semicolons but keeps the colon after a property because it is allowed and avoids ambiguity with mixin calls.
What does the nesting option do?
When a rule directly follows a rule whose selector it starts with, it is moved inside it. ".card .title" after ".card" becomes ".title" inside ".card", and ".card:hover" becomes "&:hover". Only neighbouring rules with single selectors are merged, so the compiled CSS keeps the same order.
Is the Stylus output tested with the Stylus compiler?
Not on this page. The converter is tested to produce correct structure, but the Stylus compiler is not bundled here. Run the output through Stylus in your project and compare the CSS with your original.
Does it make Stylus variables from my CSS?
No. It converts structure only. Variables, mixins and functions are choices about your design, so you add them yourself after converting, once you can see which values repeat across the file.
About this tool
Valid CSS is already valid Stylus, so this tool does the part that helps: it rewrites the file in Stylus syntax (indentation, no braces or semicolons, variables are not created) and, if you leave the nesting option on, nests a rule under the rule before it when its selector starts with that rule's selector, for example .card .title after .card, or .card:hover written as &:hover. Only neighbouring rules are merged and only single selectors without commas, so the compiled CSS keeps the same order. Rules separated by other rules are left flat. It does not invent variables or mixins. Selector lists are split one per line, and a // comment inside a declaration is dropped.