How do I minify or beautify JavaScript, CSS, or HTML online?
Paste your code, select the language (JavaScript, CSS, or HTML), and click Minify to strip whitespace and reduce file size, or click Beautify to format it with clean indentation. The tool shows the size reduction percentage. Everything runs in your browser — your code never leaves your device.
function greet(name) {
const message = "Hello, " + name;
console.log(message);
return message;
}function greet(n){const m="Hello, "+n;console.log(m);return m}Code Minifier & Beautifier
Minify or beautify JavaScript, CSS, and HTML code instantly. No data leaves your browser.
About Code Minification & Beautification
Beautify reformats your code with proper indentation, line breaks, and spacing for maximum readability. Great for reading minified production code or cleaning up messy formatting.
Minify removes all unnecessary whitespace, comments, and formatting to produce the smallest possible output. Minified code loads faster and uses less bandwidth — essential for production deployments.
JavaScript: Handles string literals (single, double, template), comments (single-line and multi-line), regex literals, and all modern syntax. Preserves semicolons and statement structure.
CSS: Handles selectors, declarations, at-rules (@media, @keyframes), comments, and nested structures. Collapses whitespace around delimiters for maximum compression.
HTML: Handles all standard tags, void elements (br, img, input, etc.), comments, DOCTYPE declarations, and embedded script/style content. Preserves content within pre and textarea tags.
Tips & Best Practices
Enable source maps alongside minification for debugging
Minification replaces variable names with single characters, making stack traces unreadable. Source maps (.map files) map minified code back to original source. Configure your bundler to generate source maps and upload them to your error tracking service (Sentry, Datadog). Never serve source maps publicly in production.
CSS minification can break specificity in rare cases
Some aggressive CSS minifiers merge selectors or reorder declarations. If your CSS relies on source order for specificity tie-breaking (two selectors with equal specificity), reordering changes which rule wins. Use explicit specificity (more specific selectors or layers) rather than relying on source order.
Gzip/Brotli compression after minification gives 80-90% reduction
Minification alone typically reduces JavaScript by 30-50%. But Gzip or Brotli compression on the minified output achieves 80-90% total reduction. Enable both: minify during build (removes dead code, shortens names) and compress during transfer (HTTP Content-Encoding). They're complementary, not alternatives.
Minification is not obfuscation
Minified code is smaller but not secret. Variable shortening is trivially reversed with a beautifier. If you need to protect client-side logic (license checks, API keys), move it to the server. No client-side technique — including obfuscation — prevents a determined attacker from reading your JavaScript.