All articles
DeveloperJul 31, 2026 · 4 min read

How to Minify CSS, JavaScript, and HTML (Free)

Minifying means stripping everything a browser doesn't need — comments, whitespace, line breaks, and (for JavaScript) long variable names — so files download and parse faster. Smaller assets mean quicker page loads and better Core Web Vitals. Here's how to minify CSS, JavaScript, and HTML for free, right in your browser.

Minify each type

  • CSS Minifier — powered by csso, which also compacts and merges rules for extra savings.
  • JavaScript Minifier — powered by Terser, the industry-standard JS minifier; it even shortens names where it's safe.
  • HTML Minifier — removes comments and collapses whitespace while keeping <pre>, <script>, and <style> contents intact.

Each one is the same flow: paste your code, and the minified output plus the size saved appears instantly. Copy it or download the file.

How much smaller?

It depends on how much whitespace and how many comments your source has, but 30–70% reductions are typical for hand-written CSS and JS. Each tool shows the before/after byte size and the percentage saved so you can see the win.

Minify vs. beautify

Minifying is the opposite of formatting. When you need to read or debug messy code, use the Code Beautifier to expand and indent it. Minify for production; beautify for development.

Is it safe to paste my code?

Yes — every minifier runs entirely in your browser. Your code is never uploaded to a server, so it's safe to paste proprietary CSS or JavaScript.

Don't forget your SVGs

SVG files exported from design tools are often full of editor metadata and can be shrunk a lot too. The SVG Optimizer cleans them up without changing how they look.

FAQ

Is my code uploaded anywhere?

No — minification runs entirely in your browser; your code never leaves your device.

Will minified JavaScript still work?

Yes — Terser preserves behavior while removing whitespace and shortening names safely. If there's a syntax error, it's reported so you can fix it.

Can I reverse minification?

You can re-format (beautify) it for readability, but original comments and variable names can't be recovered. Keep your source files.