Three languages, one page
The tool has a mode for each of HTML, CSS and JavaScript, and a "Load sample" button that follows whichever mode you are in, so you can see the effect before you paste your own file. JSON has its own place here: the JSON Formatter both minifies it and checks that the result still parses.
Two options control the whole thing. Remove comments strips the comment syntax of the selected language. Collapse blank lines and indentation removes the whitespace that carries no meaning. After each run, three figures show the original size, the minified size and the percentage saved.
What each mode does
- HTML — comments are removed, whitespace between tags is collapsed, and the gap between a block-level tag and the next tag disappears entirely. The contents of
script,style,preandtextareaare left alone and minified with the matching minifier instead, so inline scripts and styles do get stripped. - CSS — comments go, the spaces around punctuation go, and the last semicolon before a closing brace is dropped. Strings are respected, so a value containing a brace or a space survives intact.
- JavaScript — comments go and runs of whitespace collapse to a single space, but a space is kept wherever two words would otherwise merge into one. String literals, template literals and regular expressions are copied across untouched.
How to use it
- Paste the file into the input panel and select the language. Getting this right matters — HTML rules applied to JavaScript will not produce valid output.
- Press Minify and read the three size figures to see what the change is worth.
- Copy the result, or download it with the extension that matches the language.
- Open the minified file once before you ship it. If it renders differently, the safe move is to keep the readable original.
Good to know
- This is a text-level minifier, not a build step. It does not rename variables, drop unused code, convert ES6 to ES5 or add a hash to the filename. For a production bundle, use a real bundler.
- If the minified JavaScript turns out not to parse, the tool falls back to a conservative version that only strips comments and keeps the original line structure, rather than handing you broken code.
- Removing the trailing semicolon before a closing brace is safe in CSS but not in JavaScript, which is why the JavaScript mode keeps its semicolons and line breaks.
- Minifying HTML that contains
preortextareacontent will not touch that content, but the surrounding markup still shrinks. Check the result if those elements matter. - Keep the readable file. The minified version is an artefact to ship, not a version to edit.