CSS Beautify/Minify
Format or minify CSS stylesheets. Beautify adds indentation and line breaks; minify removes comments and whitespace.Overview
The CSS Beautify/Minify tool supports:- Beautify — Indents rules, properties, and selectors with 2 spaces
- Minify — Removes comments, collapses whitespace, and strips unnecessary characters
Use Cases
Code formatting
Standardize CSS indentation for readability and team consistency
File size reduction
Minify CSS for production to reduce bandwidth and load time
Debugging
Beautify minified CSS from third-party libraries or CDNs
Version control
Format CSS before commits to improve diffs
Actions
- Beautify
- Minify
Indents rules and properties with 2 spaces per level.Input:Output:
Implementation Details
Beautify Algorithm
- Normalize braces and semicolons to create line breaks
- Split by newlines and track indentation depth
- Increase indent after
{, decrease before} - Join with proper indentation (2 spaces per level)
lib/tools/engine.ts:233-260
Key logic
Minify Algorithm
- Remove CSS comments (
/* ... */) - Collapse consecutive whitespace to single spaces
- Strip spaces around syntax characters (
{,},:,;,,) - Remove trailing semicolons before
}
lib/tools/engine.ts:262-270
Key logic
The beautifier uses basic regex-based parsing. Complex scenarios (nested at-rules, vendor prefixes, or CSS-in-JS) may not format optimally.
Keyboard Shortcuts
Cmd/Ctrl+Enter— Beautify (default)Cmd/Ctrl+Shift+C— Copy outputCmd/Ctrl+Shift+S— Download output
Related Tools
SCSS Beautify/Minify
Format or minify SCSS (Sass) stylesheets
LESS Beautify/Minify
Format or minify LESS stylesheets
HTML Beautify/Minify
Format or minify HTML markup