FormatterHQ

CSS to Stylus Converter

Turn CSS into terse Stylus: no braces, colons or semicolons, with rules nested under their parent selector and pseudo-classes written as &:hover.

Input CSS
Output STYLUS
Ready.

How to use the CSS to Stylus Converter

  1. Paste your CSS into the Input editor, or use Sample, Upload file or Load URL.
  2. Press Convert. With Auto update on, the Stylus output follows your edits.
  3. Review the nested Stylus and add variables or mixins where values repeat.
  4. Use Copy or Download above the output panel to take the Stylus file with you.

What the CSS to Stylus converter does

Stylus accepts plain CSS, but most Stylus code is written in its minimal form: selectors on their own line, properties indented beneath them, and no braces, colons or semicolons. This CSS to Stylus converter produces exactly that style. It parses your stylesheet, nests rules that share a parent selector, converts pseudo-classes to & references, and prints each declaration as property value.

Example

.nav{display:flex}.nav a{color:#333}.nav a:hover{color:#0f766e}@media (max-width:600px){.nav{flex-direction:column}}
.nav
  display flex
  a
    color #333
    &:hover
      color #0f766e

@media (max-width:600px)
  .nav
    flex-direction column

Four CSS rules became two nested blocks. The media query stays at the top level with its rules indented inside it.

Stylus syntax in the output

  • Properties are written as name value with a space. Stylus also accepts name: value, so you can add colons back where they improve readability, for example in long grid-template-areas values.
  • Nesting is by indentation, 2 spaces per level.
  • Comments are kept as /* */ blocks; Stylus also supports // line comments, which are removed at compile time.
  • Empty rules get a // empty placeholder line, since an indented block needs at least one line.

Adding Stylus features afterwards

Once converted, you can introduce Stylus variables without any prefix (brand = #0f766e, then color brand), mixins that look like functions (rounded(r = 4px)), and arithmetic with units (padding gap * 2). Because Stylus variables can look like CSS keywords, many teams use a $ prefix ($brand) to keep them recognizable. Check the resulting stylesheet with the Stylus Compiler.

Stylus shortcuts worth adopting

  • Parent suffixes: &-title inside .card compiles to .card-title, handy for BEM-style names.
  • Property lookup: @width refers to the value of width already set in the same block, so margin-left -(@width / 2) centers an element without repeating the number.
  • Root reference: starting a nested selector with / places it at the root instead of under the parent.

These are optional; the converted file works as it is.

Limitations

  • Values are copied as written; the converter never creates variables or mixins.
  • Compound selectors (.btn.active) and selector lists stay as separate rules.
  • Stylus's transparent mixins mean a property name that matches a mixin name you define later would call the mixin. Avoid naming mixins after CSS properties unless that is your intention.

Considering Sass instead? CSS to SCSS produces the same nesting with braces. Conversion runs in your browser.

Checking the converted file

Indentation carries the structure in Stylus, so a few habits keep the converted file working as you edit it:

  • Keep indentation consistent. The output uses two spaces. Mixing tabs and spaces while editing is the most common cause of rules ending up under the wrong parent.
  • Shorthand with a slash. A value such as font 14px/1.5 Georgia, serif stays literal in a property value; Stylus only divides when you wrap the numbers in parentheses, as in (14px / 2).
  • Imports of plain CSS. @import 'reset.css' is passed through as a normal CSS import, while imports without the extension are resolved as Stylus files.

To confirm nothing changed, compile the Stylus with the Stylus Compiler, format both stylesheets the same way and compare them in the diff checker. Apart from grouping and whitespace, the rules should be identical.

Frequently asked questions

Is CSS valid Stylus?
Yes, Stylus accepts regular CSS syntax. This converter rewrites it into the minimal indentation-based style that most Stylus projects use.
Can I keep colons in the output?
The converter omits them, but Stylus accepts both property value and property: value, so you can add colons wherever you like.
Does it create Stylus variables?
No. Values stay exactly as in your CSS. Add variables for colors and spacing after converting.
What happens to @media queries?
Each media query stays at the top level, and the rules inside it are nested and indented like the rest of the file.

Last updated September 26, 2026

Related tools

Stylus to CSS Converter Convert Stylus to CSS online. Compiles variables, mixins and nesting into plain CSS. LESS to Stylus Converter Convert LESS to Stylus online. Rules sharing a selector are nested automatically. SASS to Stylus Converter Convert SASS to Stylus online. Rules sharing a selector are nested automatically. SCSS to Stylus Converter Convert SCSS to Stylus online. Rules sharing a selector are nested automatically. Stylus to LESS Converter Convert Stylus to LESS online. Rules sharing a selector are nested automatically. Stylus to SASS Converter Convert Stylus to SASS online. Rules sharing a selector are nested automatically. CSS Toggle Switch Generator Generate an accessible CSS toggle switch built on a real checkbox, with custom size, colours, shape and transition, plus the HTML markup. CSS Transform Generator Generate CSS transform values — translate, rotate, scale, skew and 3D rotateX/rotateY with perspective — and see them applied to a live box. CSS Triangle Generator Make pure-CSS triangles with the border trick for tooltips, arrows and carets. Pick direction, size and colour and copy the CSS. CSS Cubic Bezier Generator Edit CSS cubic-bezier() easing curves by dragging control points, compare them with standard easings in a live animation and copy the CSS. Glassmorphism CSS Generator Build a frosted-glass (glassmorphism) card with backdrop-filter blur, transparency, saturation and border. Preview it over different backdrops. LESS Compiler Experiment with LESS syntax in an online compiler: live CSS output, highlighted error lines and an optional minified result.