CSS to Stylus Converter

A vendor widget ships plain CSS and your app is written in .styl files. Paste the stylesheet here, pick how much punctuation to drop, and get Stylus back with selectors nested and repeated values named.

.css
Stylus output.styl

Nested blocks land here, with any named values assigned at the top.

Paste CSS on the left and the Stylus rebuilds on every keystroke.

0Rules read
0Rules folded in
0Values named
0 BOutput size
Load a sample

The same rule, written three ways

Stylus treats braces, semicolons, and colons as optional. Every version below compiles to identical CSS, so the choice is about the people reading the file rather than the output. Two flat rules go in, one nested block comes out, and the punctuation drops off a step at a time.

Keep the punctuation.styl
.alert-bar {padding: 12px 16px;color: #1d4a3a;.close {opacity: 0.6;}}
Drop braces.styl
.alert-bar
padding: 12px 16px
color: #1d4a3a
.close
opacity: 0.6
Drop colons too.styl
.alert-bar
padding 12px 16px
color #1d4a3a
.close
opacity 0.6

Pick the middle one when a team writes both CSS and Stylus, since a reviewer coming from plain CSS still reads declarations at a glance. Pick the first while a migration is half finished and a file holds both dialects. The third suits people who write Stylus daily and know where the parser gets ambiguous, which is the subject of the next section.

Four places where dropping the colon changes the meaning

Whitespace syntax reads a declaration as a property followed by a value. Some values break that reading. The converter keeps the colon on the first three cases below and counts them under the output pane, so you never have to spot them yourself.

Negative valuesmargin -6px 0 0 -4px
The parser reads the leading minus as subtraction against whatever margin resolves to, not as part of the number. Written with a colon, the value stays a value. Same story for a leading plus.
Values holding a colonbackground url("data:image/svg+xml,...")
A data URI carries its own colon, and so does the old IE filter: progid:DXImageTransform syntax. Two colons on one line give the parser a split point in the wrong place.
Custom properties--badge-ink #7a4a06
A custom property has to reach the compiled CSS untouched. Keeping the colon marks it as a declaration instead of something the compiler tries to resolve at build time.
Names your mixins already useborder-radius 4px
Stylus mixins are transparent, so a mixin named border-radius in any imported file swallows this line and runs instead of the property. The converter reads one stylesheet and never sees your imports, so this one stays yours to check.

Indentation carries the structure now

With braces gone, whitespace is the syntax. Four habits keep a converted file compiling.

  1. Match the indent unit already used in the destination file. Tabs and spaces do not mix inside one Stylus file, and the compiler error points at the line after the real problem.
  2. Watch the depth. Every nesting level adds an indent, and past three or four the block drifts off the right edge while the selector it produces gets heavier than the page needs.
  3. Convert one stylesheet at a time. A whitespace driven diff is harder to review than a braced one, and a concatenated bundle produces a single wall of indentation nobody checks properly.
  4. Compile before you commit. The output here is generated from a parse of your CSS, not from Stylus itself, so a run through the real compiler is the check that counts.

Why the named values arrive with a dollar sign

Stylus assigns with = and needs no sigil at all, so brand = #2f6f57 is legal. Bare names share a namespace with property names and with those transparent mixins, which is how a variable called filter or mask turns into a puzzle three months later. The dollar prefix sits outside that namespace, so the output uses $color-1 and up.

A value earns a name after it appears twice. Three groups qualify:

What passes through untouched:

Rename before the file lands in a repository.$color-1 and $shadow-2 are numbered in order of appearance and carry no meaning. $brand-green and $card-shadow do. Use Copy the assignments to lift the block into a variables.styl partial while you rename, since that partial is where the rest of the project will look for them.

Comments come out as block comments

Stylus has two comment forms and they behave differently. A // line is dropped during compilation and never reaches the browser. A block survives into the compiled CSS. Converting a licence header or an attribution note into // would quietly delete it from your production file, so every comment stays in block form here. Turn the switch off when you want the noise gone instead.

Two other things move during conversion, worth reading in the diff. Repeated selectors merge, so a sheet declaring .btn on line 12 and again on line 400 comes back as one block, which shifts the position of any rule that sat between them. And nesting hides specificity behind indentation without lowering it, so #app .layout .link still outweighs a single class after the compile.

Is Stylus the right destination?

This page converts syntax. Mixins, functions, @extend, partials and @import layout, iteration, and the Stylus color maths are all decisions about intent, and a converter guessing at intent writes code nobody trusts. Expect a starting point, then a pass by hand.

The larger question is whether the destination is worth the trip. Stylus releases arrive rarely now and much of the tooling built around it has gone quiet, while browsers ship native CSS nesting that covers the part most people wanted from a preprocessor. If a .styl codebase already runs in production and a vendor snippet needs folding into it, this converter is the right tool. If a new project is choosing a preprocessor from scratch, Sass has the bigger ecosystem and plain CSS with native nesting has no build step at all.

Everything runs inside your browser tab, so a client stylesheet uploads nothing and nothing persists between visits. A few thousand rules convert in well under a second. When you want to check the trade, send the result through the Stylus to CSS converter and diff the compiled output against the file you started with.

Questions that come up mid conversion

What people ask once a real stylesheet is sitting in the left pane.

Does the Stylus compile back to my original CSS?

Rule for rule in almost every case. Nesting and punctuation are syntax, and assignments resolve at compile time to the values they replaced. Two things shift: repeated selectors merge into one block, which moves any rule that sat between them, and a stylesheet leaning on source order rather than specificity deserves a diff of the compiled output before you commit.

Which output level should I pick?

Drop braces is the common house style in Stylus projects and the safe default here. Keep the punctuation suits a codebase halfway through a migration where reviewers still read CSS. Drop colons too is for teams already fluent in Stylus, and even then the converter keeps colons on negative values, custom properties, and values carrying their own colon.

Why does one declaration still have a colon in bare mode?

Because removing it would change what Stylus reads. A leading minus becomes a subtraction operator, a data URI or an old progid filter puts a second colon on the line, and a custom property has to survive to the compiled CSS untouched. The count under the output pane tells you how many lines took the exception.

What happens to my comments?

They come through as block comments. Stylus drops double slash comments during compilation, so a licence header rewritten that way would vanish from your production CSS. Uncheck Keep comments when you want them stripped instead.

Can it use plain names instead of the dollar prefix?

Not from this page. Stylus allows bare names, but they share a namespace with property names and with transparent mixins, so a bare assignment called mask or filter is a bug waiting for the right import. Renaming the block by hand after you copy it takes one pass and gives the names real meaning.

Are keyframes and font faces converted too?

They are reindented and stripped of punctuation with everything else, and their contents are left exactly as written. No value inside a keyframe step or a font face block gets pulled into an assignment, because a named value inside animation timing tends to hide the thing you are debugging.

Is my stylesheet sent anywhere?

No. Parsing, nesting, naming, and the clipboard write all run in JavaScript inside your tab. Nothing is uploaded and nothing is stored between visits, so a stylesheet from a client project is safe to paste.

Should I still be starting projects on Stylus?

Probably not. Releases are rare now, the surrounding tooling has thinned, and native CSS nesting ships in browsers. This converter earns its place when a Stylus codebase already exists and something written in plain CSS needs to join it.