CSS and HTML run locally; JavaScript uses terser, about 1 MB, loaded on demand.
3
Copy the result
The before and after sizes and the percentage saved are shown.
What minification can and cannot do
Minification removes characters that do not change behaviour: comments, indentation, and whitespace where the grammar allows it. It does not compress the bytes; gzip or Brotli does that, and the two together are smaller than either alone. It also does not make code faster in any meaningful way, because the parser's work is dominated by the code inside, not by the spaces.
Always test after minifying. The classic failures are a missing semicolon that a line break used to supply, a comment that contained a conditional-compilation directive, and code that reads a function's source text. None of those can be detected by a minifier.
The CSS and HTML rules used here
CSS is processed character by character so strings and url() contents are left alone; comments are removed and whitespace is collapsed around braces, colons, commas and combinators. HTML loses comments (except conditional comments), newline gaps between tags are closed up, and everything inside pre, textarea, script and style is left exactly as written.
This is deliberately conservative. A more aggressive CSS minifier merges rules and rewrites colours, which changes the cascade in ways that are hard to review. If you need that, use a build tool with a source map so the result can be debugged.
JavaScript, terser and mangling
JavaScript is minified by terser, a real parser and compressor rather than a whitespace stripper. It removes dead code, shortens syntax and can rename local variables when mangling is enabled. Mangling makes the output smaller and stack traces harder to read, so it is a separate option.
Terser is about 1 MB and is loaded from this site only when you press Run, which the page states before you click. Your code is not uploaded: the library runs in the tab. Property names are not mangled, because doing so safely requires knowing every access path.
Frequently asked questions
Is minified code safe to deploy?Test it first. Minification can expose a missing semicolon or a directive inside a comment, and no tool can prove otherwise.Does it produce a source map?No. For production builds, use a build tool that emits one alongside the minified file.Are pre and textarea blocks preserved?Yes. Their contents are left exactly as written, including whitespace.Why is my file bigger after minifying?Usually the input was already minified, or a string contained whitespace that was preserved. Check the sizes reported.Is my code uploaded?No. CSS and HTML are processed in this tab; terser is downloaded to the tab and runs there.Which terser version?The current 5.x bundle, served from this site under its BSD licence.