CSS Formatter, Minifier & Beautifier Online

Paste CSS, load a sample, or upload a .css file. Validate and beautify it for easier editing, or minify it for delivery, then compare exact sizes and export the result without uploading your stylesheet.

Advertisement

Drop a .css file here. Tab moves focus; Ctrl/Cmd+] indents. Untitled input

Generated output can be adjusted before copyingNo output
Loading local processing engines…
0 BInput · 0 chars · 0 lines
0 BOutput · 0 chars · 0 lines
Bytes saved · reduction
Output gzip estimate

Processing Options

Minification preset

Optimized mode can move or combine compatible declarations. CSS cascade order and browser-specific workarounds can be intentional, so test the output on the target site.

Beautifier
Use 0 to disable wrapping; accepted range is 0–500.

How to Format or Minify CSS Online

  1. Paste CSS, choose Try Sample, or upload/drop a .css file.
  2. For minification, choose Safe or Optimized and decide whether to retain exclamation comments. For formatting, choose indentation and line-wrapping options.
  3. Select Minify or Beautify / Format. CSS Tree parses the stylesheet first; syntax errors include a line and column when available.
  4. Compare the exact UTF-8 byte, character, line, reduction, and gzip figures, then copy or download the output.
  5. Test the exact output in its intended pages and browsers before replacing a production file.

CSS Minification and Formatting Examples

Minification: Before → After

Before
/*! MIT */
.card {
  color: #ffffff;
  margin: 0px 16px;
}
Safe output
/*! MIT */.card{color:#fff;margin:0 16px}

Whitespace is removed, zero units and colours can be shortened, and the exclamation comment is retained when that option is enabled.

Beautification: Before → After

Before
@media(min-width:48rem){.card,.panel{display:grid;gap:1rem}}
Formatted output
@media (min-width: 48rem) {
  .card,
  .panel {
    display: grid;
    gap: 1rem;
  }
}

Indentation and line breaks are added while the at-rule, selector list, declarations, and values remain CSS.

Practical CSS Formatting and Minification Guide

What CSS Minification Does

A CSS minifier parses a stylesheet, removes comments and optional whitespace, shortens compatible values, and prints fewer bytes. Safe mode disables cross-rule restructuring. Optimized mode can also merge or reorganize compatible rules. Neither mode removes selectors based on the HTML that uses them.

Formatting vs Minification

Formatting is for reading, reviewing, and editing. It adds consistent indentation and line breaks but does not reconstruct an author's exact source. Minification is for delivery. Keep a readable source file in version control and treat minified CSS as a generated artifact.

Why Smaller CSS Helps

Fewer bytes can reduce transfer and parse work, especially across many visits or on slower connections. Web servers and CDNs should also apply gzip or Brotli. Transport compression and minification complement each other: one encodes repeated bytes, while the other removes or simplifies source characters.

Cascade and Compatibility Checks

CSS behavior depends on selector specificity, source order, layers, inheritance, custom properties, and browser support. Optimizers are designed to preserve behavior, but legacy hacks, unusual vendor syntax, and deliberately repeated fallbacks deserve visual regression testing.

When a Build Pipeline Is Better

Use PostCSS, Lightning CSS, CSSO, clean-css, or a bundler integration when you need repeatable builds, source maps, prefixing, nesting transforms, imported files, asset rewriting, or automated tests. A browser tool is most useful for snippets, one-off files, and inspecting compact CSS.

Validation Limits

Parsing confirms that the processing engine can understand the stylesheet; it is not a complete standards or browser-compatibility audit. Unknown property names and many unknown values are valid CSS grammar, while support differs by browser. Use browser developer tools and compatibility data for deployment decisions.

CSS Formatter, Minifier & Beautifier FAQ

What is the difference between CSS formatting and minification?

Formatting adds consistent indentation, spacing, and line breaks for people to read. Minification removes unnecessary bytes and may optimize equivalent CSS for delivery. Formatting normally increases file size; minification normally reduces it.

Is my CSS uploaded or stored?

No. CSS is sent only to a Web Worker inside the current browser tab. Starlight Tools does not upload it or save it in local storage. The page downloads its open-source processing engines from CDNs, but stylesheet content is not included in those requests.

Can a beautifier restore the original CSS source?

No. A beautifier can restore readable whitespace and indentation, but it cannot recover removed comments, the author's original formatting, or transformations made by an optimizer. Keep the source stylesheet in version control.

Does CSS minification change how a page looks?

It is intended to preserve CSS behavior, but an optimized preset may combine or restructure compatible rules. Cascade order, browser quirks, unsupported syntax, and build-time conventions can matter, so test the exact output before deployment.

Are Sass, SCSS, Less, or CSS Modules supported?

No. This page accepts standard CSS. Compile Sass, SCSS, or Less first. CSS Modules selectors may parse as CSS in some cases, but module-specific build behavior is outside this tool.

Can licence comments be kept?

Yes. Enable Preserve exclamation comments to retain comments beginning with /*!, a common convention for licence notices. Review the result because a project's licence obligations can require other text or files.

When should I use a build-pipeline minifier?

Use a repeatable build pipeline for production projects with multiple files, source maps, PostCSS plugins, preprocessors, automated testing, or browser-specific transformations. This online tool is best for snippets, one-off files, and quick comparisons.

Explore more tools