CSS formatter and minifier
Beautify messy CSS or minify it for production, with the size saved. Free, no sign-up, and everything runs in your browser.
Action
Indent
Paste a stylesheet. The result updates as you type.
Formatted CSS
/*! Launch page styles */
.hero,
.hero--dark {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
gap: 24px;
padding: 64px 16px;
}
.hero h1 {
font: 700 clamp(2rem, 5vw, 3.5rem)/1.1 "Inter", system-ui, sans-serif;
margin: 0 0 16px;
}
/* Call to action */
.cta > a:not(.secondary):hover {
background: url(/img/arrow.svg) no-repeat right center;
color: #fff !important;
}
@media (max-width: 600px) {
.hero {
padding: 32px 16px;
}
.cta {
display: none;
}
}
What this CSS formatter does
This tool takes a stylesheet in any shape and gives it back in the shape you need. Beautify puts each selector and each declaration on its own line, indents nested blocks, and adds one space after every colon and comma. Minify does the opposite: it removes comments, line breaks and every space the browser does not need, so the file is smaller.
It only changes whitespace, comments and the last semicolon in a block. It never rewrites selectors or values, so the output means exactly the same as the input. Strings, url() values, !important, media queries and native CSS nesting stay as they are. Everything runs in your browser tab, and nothing is uploaded.
How to format or minify CSS
- Paste your CSS into Your CSS. Minified CSS from a live site works too: open the stylesheet in your browser's developer tools and copy it.
- Pick Beautify to make it readable, or Minify to make it small. The result updates as you type.
- When you beautify, pick an indent of 2 spaces, 4 spaces or a tab. When you minify, choose whether to keep comments that start with
/*!. Tools and authors use that form for license notes that must stay in the file. - Select Copy CSS, or Download to save the result as a .css file. The badge shows the size before and after.
If the tool finds a problem, such as a block that is never closed or a line without a colon, it lists the line number. It still makes the output, but fix the line first: browsers do not show CSS errors. They skip the broken part without a warning and keep going, so one missing brace can quietly drop the rules after it.1
Why minify CSS
A browser must download and read your CSS before it can draw the page, so smaller files help pages show up sooner. Google's Lighthouse audit flags unminified stylesheets and estimates the savings from the comments and whitespace it finds.2 Google's guide suggests a build step that minifies CSS automatically for sites you deploy often, and a paste-in tool for small sites you rarely change.2 This tool covers the second case and any time you have no build step, such as a static landing page, a theme file in a site builder, or a quick snippet for an email or a widget.
Minify for production and keep the readable version as your source. You can always beautify a minified file again to read or edit it. If you are tuning a site before a product launch, also check that crawlers can reach your stylesheets with the robots.txt tester, and compare two versions of a file with the diff checker.
More free tools
ASCII table and converter
ASCII table with all 128 codes in decimal, hex, octal and binary, plus a converter from text to ASCII codes and back. Runs in your browser.
Keycode finder
Keycode finder that runs in your browser. Press any key to see its JavaScript keyCode, key, code and location, and copy a ready keydown handler.
Image converter
Image converter that runs in your browser. Convert PNG, JPG, WebP, AVIF, GIF and SVG files in bulk, with quality and resize options. No uploads.
HTML to Markdown converter
HTML to Markdown converter that runs in your browser. Paste HTML or rich text from a web page, Google Docs or Word and get clean GitHub Markdown.
Test credit card numbers generator
Test credit card numbers for form and checkout tests, made in your browser. Generate valid-format numbers for 7 card networks and check any number.
PX to REM converter
PX to REM converter that runs in your browser. Convert px to rem and rem to px at any root font size, or convert a whole stylesheet at once.
Frequently asked questions
Sources
MDN Web Docs: CSS error handling
Chrome for Developers: Minify CSS (Lighthouse audit)
MDN Web Docs: Comments
W3C: CSS Syntax Module Level 3 (consume comments)
MDN Web Docs: Using CSS nesting