CSS minifier
Remove safe formatting bytes while preserving rule order, duplicates, custom properties and unknown at-rules.
- SECURE
- NO UPLOADS
- NO SIGNUP
- BROWSER BASED
- FREE
- FOREVER.
Support us with a link or a share
- UTF-8
- —
- Characters
- —
- Input
- —
Conservative serialization only. Rule order, duplicate declarations, custom properties, escapes, layers and unknown at-rules stay in the parsed structure. No SCSS, structural optimization or source maps.
The worker will return output only after two separate representations agree:
- Reparse and compare the complete CSS syntax tree.
- Retokenize and compare the canonical token stream.
A CSS minifier must respect the cascade
CSS is not a bag of independent declarations. Source order decides which rule wins, repeated declarations can provide deliberate fallbacks, and an unknown at-rule may be meaningful to a newer browser or another standards-based processor. Removing or moving any of those things is optimization, not whitespace cleanup.
This tool uses css-tree as a parser and conservative serializer. It never
runs a structural optimizer: rules are not merged, selectors are not combined,
declarations are not deduplicated, and no optimizer shortens values or colors. The
serializer can choose a canonical spelling for parsed syntax. Comments and formatting whitespace are removed only where the CSS grammar
lets the serializer reproduce the same parsed structure.
Why minified CSS still contains spaces
Some whitespace is syntax. In calc(100% - 2rem), the spaces around the
binary minus distinguish an operator from a signed number. A comment can also be the
only boundary between two identifier tokens. If red/**/blue became
redblue, the token stream would change. Conservative serialization replaces
such a comment with the separator the grammar needs.
Custom-property values deserve the same caution because their token sequence is kept for
later substitution by var(). Escaped identifiers, cascade layers,
!important, duplicate declarations and unknown at-rules all appear in the
regression corpus rather than being treated as edge cases.
Two checks before a result exists
The compact stylesheet is parsed a second time. Its complete syntax tree must match the tree parsed from your input. The generated form is then tokenized separately; invalid string or URL tokens are rejected, and the canonical token stream must be stable across the reparse. If either check disagrees, the worker returns an error and no output.
These checks establish a narrow claim: the parser sees the same structure and the tokenizer sees the same canonical tokens. They are not a claim that every browser bug, vendor extension or future syntax can be predicted. Invalid input is stopped rather than repaired, and browser-ready CSS is the boundary of the tool.
Compile SCSS before minifying
SCSS variables, interpolation, mixins, functions and line comments are instructions for a preprocessor. Their meaning can depend on imports, configuration and a project build, none of which exists in a pasted snippet. Compile the source in its real project first, then submit the emitted CSS here.
The same boundary explains why there is no source-map download. A useful map connects generated bytes to original files and build steps. A browser-only minifier that sees one text field cannot honestly reconstruct that provenance. The output is a single verified CSS file, processed in a local worker and never uploaded.
Questions
Does this CSS minifier remove duplicate declarations?
No. Duplicate declarations can be intentional fallbacks, and rule order is part of the cascade. The tool only parses and conservatively serializes your stylesheet; it does not merge rules, deduplicate declarations, reorder properties or run a value-shortening optimizer.
How does it check the minified CSS?
The compact output is parsed again and its syntax tree is compared with the input tree. A separate tokenizer then checks the canonical token stream and rejects invalid string or URL tokens. No result is returned if either oracle disagrees.
Why must calc() keep some spaces?
In CSS math functions, binary plus and minus operators require surrounding whitespace. Removing every space blindly can turn a valid calculation into invalid CSS. The serializer keeps grammar-required separators, including spaces that replace comments between tokens.
Can it minify SCSS or Sass?
No. SCSS variables, interpolation, mixins and line comments need a preprocessor and project configuration before they become browser CSS. Compile SCSS first, then minify the resulting .css file here.
Does it create a source map?
No. A useful source map must connect generated CSS to the original source files and build pipeline, not just to pasted text. This tool returns one verified CSS file and does not claim build-system provenance it cannot know.
Is the stylesheet uploaded?
No. File reading, css-tree parsing, serialization and both verification passes run in a local web worker in this browser tab. The page has no upload or remote minification step.