Skip to content

Code Minifier

Make JavaScript, CSS, HTML and JSON smaller by removing comments and spaces, safely, with the size before and after.

  • Free, no sign-up
  • Runs in your browser
  • Sources cited

JavaScript, CSS, HTML or JSON. The language is detected unless you choose it.

Minified

Before
184 bytes
After
129 bytes
Saved
29.9%
Minified as CSS. Only comments and spaces are removed; names and code stay exactly as written. Licence comments starting /*! are kept.

Everything runs in your browser. Nothing you enter is uploaded.

How to use the code minifier

  1. Paste or open the code

    Paste JavaScript, CSS, HTML or JSON, or open a file. The language is detected, or you can choose it.

  2. Check the result

    The minified code appears as you type, with its size before and after and the share saved.

  3. Copy or download

    Copy the minified code or download it with the right file extension.

How minification works

Minification removes characters that computers do not need, such as comments, indentation and line breaks, so files download faster. This tool reads each language token by token, so strings, template literals, regular expressions and quoted values are never touched, and it removes only what cannot change the meaning. It does not rename variables or rewrite code; build tools that do so can shrink JavaScript further, at the cost of readable output.

JavaScript needs care because a line break can end a statement: the rules for automatic semicolon insertion mean that joining two lines can change what code does. The minifier keeps a line break wherever one statement could end and the next begin, and keeps the space in expressions such as a - -b. CSS follows the CSS syntax rules: spaces around braces, colons and commas go, but the space between selectors that means “inside” stays.

In HTML, runs of spaces in text collapse to one, as browsers display them, and spaces between block elements go; text inside pre and textarea is kept exactly, and inline scripts and styles are minified too. Licence comments that start with /*! are kept. Everything runs in your browser.

Worked example

The example CSS is 184 bytes. Minified it is 129 bytes, 29.9% smaller: .price-card{display:grid;gap:1rem;padding:1.5rem 2rem;border-radius:12px}.price-card>.amount,.price-card>.period{font-weight:700}.

In JavaScript, “let x = y ⏎ ++z” becomes “let x=y ⏎ ++z”; the line break stays because removing it would change which statement the ++ belongs to.

Understanding the result, and common mistakes

  • Editing minified files. Keep the original source and minify again after each change.
  • Expecting compression to stack up. Servers usually compress files too, which narrows the difference minifying makes on the wire.
  • Losing licence notices. Start them with /*! so they are kept.

Frequently asked questions

Can minifying break my code?

This minifier only removes comments and spaces that cannot matter, and keeps line breaks where JavaScript might need them. Test the result as you would any change.

Does it rename variables?

No. Names stay as written, so the output is still readable and debuggable.

Is my code uploaded?

No. It is minified in your browser.

Sources

  1. MinificationMDN Web Docs · retrieved Nov 14, 2026
  2. ECMAScript: Automatic Semicolon InsertionEcma International · retrieved Nov 14, 2026
  3. CSS Syntax Module Level 3World Wide Web Consortium · retrieved Nov 14, 2026
  4. How whitespace is handled by HTML, CSS, and in the DOMMDN Web Docs · retrieved Nov 14, 2026

About these results

  • Code is minified in your browser. Nothing you paste is uploaded.