CSS minifier: compress, beautify and review your stylesheet
Admin ·
A CSS minifier reduces stylesheet source by removing unnecessary text and using shorter forms. ToolMellow provides separate Minify CSS and Beautify CSS actions: one produces compact CSS, while the other prints readable indentation. Paste a stylesheet or open a local text file, then review the separate Result before using it.
Start with flat CSS that is ready for deployment. Compile nesting or preprocessors in your project first. The minifier refuses some syntax it cannot safely parse, but successful processing does not validate every property, preserve every comment or prove that the result behaves correctly in your pages.
Process the whole stylesheet and keep the original
Try the built-in example to see how the two actions differ. For your own source, paste into Input or choose a local stylesheet. Both actions process the whole Input; highlighting a selection does not restrict minification or beautification to that selection.
A successful run leaves Input unchanged and creates a read-only Result. Editing Input or changing a processing option clears the previous Result, so run the chosen action again after a change. Save the original before replacing it with exported or reused output.
- Use flat CSS and keep a copy of the original stylesheet.
- Choose whether to keep top-level important comments or remove all comments.
- Leave rule restructuring off initially, or enable it after reviewing the tradeoff.
- Run Minify CSS for compact output or Beautify CSS for readable indentation.
- Check the complete result, required notices, reported errors and byte counts.
- Copy or download the full Result, then test it in the project where it will run.
Know which controls each action uses
Minify CSS uses the comment and rule-restructuring choices. Beautify CSS uses the indentation choice and a separate formatting path. A minification setting therefore does not tell the beautifier to remove comments or merge rules.
Indentation starts at two spaces, important-comment mode is selected, and restructuring starts off. Wrap lines is an editor display preference. The controls do not provide a browser-target list, a project scan or a source-map export.
| Control or action | Value here | Effect |
|---|---|---|
| Minify CSS | Compact stylesheet output | Uses comment and restructuring settings. |
| Beautify CSS | Readable stylesheet output | Uses the indentation setting. |
| Indentation | 2 or 4 spaces; default 2 | Changes beautification, not minification layout. |
| Comments when minifying | Keep important (!) or Remove all | Important-comment retention depends on placement. |
| Allow rule restructuring | Off by default | Enables an additional structural optimization pass. |
| Wrap lines | Display only | Does not insert source line breaks. |
| Result | Read-only | Receives successful output separately from Input. |
| Size notice | UTF-8 bytes and rounded percentage | Can report a smaller or larger result. |
CSSO: minification API and compression optionsPrettier formatting options
Important comments need a placement check
The default minification mode keeps top-level comments written as /*! ... */. Ordinary comments are removed. Important comments inside a rule or a nested block may still disappear: the setting is not a promise to preserve every comment containing a notice.
For example, a top-level /*! attribution */ can remain while the same comment inside .a { ... } is lost during minification. Review every required notice in Result before using it. Remove all also removes retained top-level important comments. Beautify CSS follows its own formatting path and does not use this removal setting.
Off still allows compression beyond whitespace
Rule restructuring is off by default. Minification still performs cleaning and shorter-form replacements: a color such as #ffffff can become #fff, and a zero length such as 0px can become 0. Turning off restructuring does not make the operation a whitespace-only edit.
Enabling restructuring can combine or reorganize rules. In an observed example, .a{color:red}.b{color:red} becomes .a,.b{color:red} with it enabled. Compare the result and test the stylesheet in its target application; neither setting provides a universal rendering-equivalence guarantee.
| Situation | Useful starting point | What to review |
|---|---|---|
| First pass on an unfamiliar stylesheet | Leave restructuring off | Value shortening and other compression still occur. |
| Repeated compatible declarations | Try restructuring on | Rules may merge or move as part of optimization. |
| Order-sensitive overrides | Keep the original for comparison | Check cascade behavior in the actual project. |
| Media and conditional rules | Inspect the resulting groups | Do not infer compatibility from a smaller byte count. |
| Unused selectors | Use project-aware tooling separately | This workspace does not scan pages or remove selectors based on usage. |
| Browser support requirements | Use the project build and tests | There is no browser-target configuration here. |
Beautify for inspection, not to recover lost information
Beautify CSS prints source with two or four spaces. It can make a compact stylesheet easier to read, and ordinary or important comments present in that input can remain in the formatted output. Comment removal and restructuring choices are not applied to this action.
Beautifying minified text cannot reconstruct removed comments, the original whitespace or the original rule organization. Both actions read Input, not the other action’s Result. Use result as input first if you deliberately want to beautify a minified result, and keep the original separately.
Compile nesting and preprocessors before minifying
Provide a complete flat stylesheet rather than only declarations such as color:red;margin:0;. Compile Sass, Less and nested CSS in the project that owns them before using Minify CSS. This workspace does not resolve imports, expand variables or produce a project bundle.
The two parsers can accept different source. A nested selector such as .a{color:red;&:hover{color:blue}} can be printed by Beautify CSS while Minify CSS refuses it. A successful beautification therefore does not establish that the same source is supported by minification or ready for a target browser.
A refusal protects against partial output, not every CSS mistake
If minification cannot safely parse some rules or declarations, it stops instead of returning CSS with that source silently discarded. Input remains available and there is no successful partial Result. Check the source, compile unsupported syntax to flat CSS where needed, and run the action again.
Other input can still be accepted permissively. An observed missing closing brace was printed as closed, and unknown property names or values can remain in output. Read any localized error summary and expand the original technical detail, which may be in English. A reported line and column is available for some parser errors, but not every refusal has a position.
Read byte savings as source size
The size notice compares Input and Result as UTF-8 bytes, with decimal B, KB or MB labels and a rounded whole percentage. It is a source-text comparison. It does not measure gzip or Brotli transfer size, page loading speed or the effect of caching.
Beautification can increase size because it adds readable layout. An empty rule or ordinary-comment-only input can minify to an empty Result. A zero-length successful result is still exportable; check whether it is the result you intended instead of judging success only by a smaller number.
| Displayed fact | Meaning | Limit of the comparison |
|---|---|---|
| Input bytes | UTF-8 size of current Input | Different from visible characters and UTF-16 input units. |
| Result bytes | UTF-8 size of the complete Result | Not a compressed network-transfer measurement. |
| Smaller percentage | Rounded byte reduction | Not a page-speed or behavior guarantee. |
| Larger percentage | Result has more UTF-8 bytes | Can be expected after beautification. |
| Empty successful output | No source text in Result | Can follow removal of comments or empty rules. |
File bytes and decoded text have separate limits
Input allows at most 1,000,000 UTF-16 code units. That differs from UTF-8 bytes and from visible characters: a supplementary character such as 🌿 uses two UTF-16 units. A local file must pass both its byte check and the decoded-text limit.
Output can expand beyond the independent input limit, particularly during beautification. Full Copy and Download remain available, while Use result as input refuses output that would exceed the input cap and retains the existing Input and Result.
| Item | Limit | Boundary behavior |
|---|---|---|
| Pasted or processed Input | 1,000,000 UTF-16 code units | Exactly the limit is allowed; larger text is refused. |
| Local file | Strictly less than 4,000,000 bytes | Exactly 4,000,000 bytes is refused before reading. |
| Decoded file text | 1,000,000 UTF-16 code units | Must fit after UTF-8 decoding as well. |
| Use result as input | 1,000,000 UTF-16 code units | Oversized Result stays available for full export. |
| Find text | 1,000 UTF-16 code units | Literal search text is bounded. |
| Replacement text | 10,000 UTF-16 code units | An edit that would exceed the input cap is refused. |
| Undo and redo history | Up to 20 older snapshots | Accepted Input changes share the bounded history. |
| Combined history text | 4,000,000 UTF-16 code units | Excludes current Input; older stored states are bounded. |
Import stylesheet source as UTF-8 text
Open text file loads local source into Input. The importer checks file bytes, decodes using the file’s text-reading method, then checks decoded length. It uses UTF-8; there is no encoding selector, and changing a filename, MIME type or CSS encoding declaration does not select a different decoding scheme.
Convert a stylesheet from another encoding to UTF-8 in a suitable editor before importing it. This workflow reads local text; it does not retrieve a stylesheet from a URL, extract CSS from PDF or Word files, or load the resources mentioned by the stylesheet.
Copy or download all of Result
Copy result and Download use the complete Result rather than a textarea selection or only its visible lines. Download creates UTF-8 text named toolmellow-result.css. If clipboard access is unavailable, select the result text and copy it manually.
The downloaded file contains stylesheet source. It does not bundle images, fonts, imported stylesheets or a source map. Keep those resources and the project’s deployment paths with the CSS, and review changes before replacing the original file.
Reuse a result deliberately and within the cap
Use result as input replaces Input with a successful Result that fits the input limit. It also clears the old Result, so run the next action afterward. Producing a separate Result alone does not replace Input or create an Input history edit.
For an observed one-million-unit comment input, beautification adds a final line break and produces 1,000,001 units. The entire result can be copied or downloaded, but reuse is refused without discarding Input or Result. That refusal does not mean the exported output has been truncated.
Literal editing, display wrapping and Clear have different effects
Find and replace operates on literal text in Input, with an optional case-sensitive mode. It does not use regular expressions or rename CSS symbols throughout a project. Replacement text such as $& is inserted literally. Check matches before replacing repeated selectors, strings or URLs; an accepted edit clears the previous Result.
Wrap lines changes the Input and Result textarea display without inserting source line breaks. It does not alter copied or downloaded CSS. Code remains left-to-right even when the surrounding interface uses a right-to-left language.
Undo and redo cover accepted Input edits, imports, replacements and result reuse within the available history. They do not undo the act of creating a separate Result. Clear empties Input, Result, search text and history while retaining processing options and the wrapping preference. Clear cannot be undone.
Local processing still needs a loaded engine
Processing runs in a browser worker. The editors hold CSS as text rather than applying it to a preview page, so the workspace does not fetch the image or font URLs written in that source. This does not make arbitrary output safe to use elsewhere. Worker and engine assets may need network access when loading; local processing alone does not guarantee an offline first run.
If an engine cannot load, keep Input and try the action again after connectivity is restored. Cancel can stop pending work while preserving Input. The configured startup-and-processing deadline is 60 seconds, but actual completion time depends on the browser and source. Keep your own saved copy instead of relying on the current tab as a backup.
Test the stylesheet in the project that uses it
Compare the exported stylesheet with the original, including required notices and order-sensitive rules. Use the project’s checks and inspect the pages, responsive layouts and interactive states affected by the CSS. A smaller file does not establish that those behaviors are unchanged.
This tool does not inspect HTML to decide which selectors are unused, rewrite asset URLs for deployment, choose browser targets or verify accessibility. Keep those project tasks in the normal build and review workflow, and use minification or beautification here as one source-editing step.
Common questions
Why can an important CSS comment disappear?
The default minification choice keeps top-level /*! ... */ comments. Comments inside rules or nested blocks may be lost even with that choice. Review every required notice in Result before using it; the tool does not determine which notices you must retain.
Does turning off restructuring disable every optimization?
No. Cleaning and shorter-form replacements still run, so values and source can change beyond whitespace. Restructuring controls an additional pass that can combine or reorganize rules. Review and test either result.
Do comment settings change Beautify CSS?
No. Comment removal and rule restructuring apply to Minify CSS. Beautify CSS uses a separate formatting path and the two- or four-space indentation setting.
Does beautifying CSS restore the original stylesheet?
No. It can make compact source readable but cannot recover removed comments, original whitespace or the original organization of rules. Keep the original separately, and reuse Result as Input first if you want the next action to process that result.
Why is a CSS file under 4 MB rejected?
The file must be strictly smaller than 4,000,000 bytes, and its UTF-8-decoded text must also fit the separate 1,000,000-UTF-16-unit input cap. Byte size alone does not establish that decoded text will fit.
Can I minify only the selected CSS?
No. Both actions process the entire Input. A selection does not narrow the processing scope. Put the desired complete fragment in a separate Input if you want to process it on its own.
Why can I not use the result as input?
Output can grow beyond the input cap during beautification. If Result exceeds 1,000,000 UTF-16 units, reuse is refused while Input and Result remain intact. Full Copy and Download are still available.
Does minification validate CSS or remove unused selectors?
No. It refuses some syntax that cannot be safely parsed but can still accept recovered syntax, unknown properties or invalid values. It does not scan your pages or project for selector usage. Use appropriate project validation and usage-aware tooling separately.
Can I undo Clear?
No. Clear discards Input, Result, search text and the retained undo/redo history. Ordinary accepted Input changes can be undone only within the available history before Clear.
Can I minify native CSS nesting?
Compile nesting to flat CSS before using Minify CSS. Unsupported nested rules can be refused. Beautify CSS may print nested source, but that does not compile it or establish minification support.
Does this compile Sass or Less?
No. Use the compiler and configuration from your project, then provide its flat CSS output. The workspace does not resolve a project’s imports, variables or build dependencies.
Are the byte savings gzip or Brotli savings?
No. The notice compares UTF-8 source bytes and a rounded percentage. It does not measure compressed transfer size, caching or page loading speed, and beautification can produce a larger result.
Does the download include assets or a source map?
No. Download exports the complete UTF-8 Result as toolmellow-result.css. Images, fonts, imported stylesheets and source maps are not bundled.
Will local processing work offline immediately?
There is no offline first-run guarantee. Processing occurs in a browser worker, but the page, worker and engine assets must load. If an engine load fails, keep Input and retry once connectivity is available.