Skip to content
Changelog
new tooldeveloper & web

Code Minifier

v1.0

Code Minifier strips comments and extra whitespace from HTML, CSS and JavaScript.

It is conservative on purpose: nothing is renamed or restructured, so the output behaves like what you pasted in. Pick a language, paste or upload the source, and the minified version appears beside it with the bytes before and after and the percentage saved.

Only bytes that are safe to remove go. Comments are dropped, except license banners that start with /*! and IE conditional comments. Redundant whitespace is collapsed, and each CSS block loses its optional last semicolon. Strings, url() contents, regular expressions and template literals are left exactly as written, and the spaces inside calc() stay because they are part of its syntax. In HTML, the contents of pre, textarea, script and style are copied through untouched, and a single space between inline tags is kept because it is a visible word gap. In JavaScript a line break stays wherever removing it could change the meaning.

JavaScript is checked before it is minified. A syntax error is reported with its line and column and a Jump button that moves the cursor there, and nothing is minified until the source is valid. The error appears once you stop typing, not on every keystroke.

The Sample menu has three cases for each language: a full example with a banner, a case that is mostly whitespace and comments, and a case with the tricky parts (strings, urls, calc(), inline spacing, line breaks that matter). JavaScript also has a sample with a syntax error. Copy the output or download it as a file with the right extension. Share packs short sources into a link, and the language you chose is remembered on this device.

All changes