What minifiers do
Minification removes everything a computer does not need to read code: indentation, line breaks, comments and, for some languages, redundant characters such as optional semicolons or long local variable names. The result behaves exactly like the original but is smaller, so it downloads faster, takes less space in databases and fits into places with length limits. These minifiers cover the formats developers ship most often.
Choosing a minifier
- JavaScript – JS minify removes whitespace and comments and can shorten local names, typically the biggest saving on a website.
- CSS – CSS minify strips whitespace, comments and unnecessary units and semicolons.
- HTML – HTML minify collapses whitespace between tags and removes comments while keeping
<pre>and inline text intact. - JSON – JSON minify produces compact JSON for APIs, config values and storage; JSON to one line is handy for environment variables and log entries.
- XML – XML minify removes whitespace between elements.
- SQL – the SQL minifier turns a formatted query into a single line for embedding in code.
- Lua and text – the Lua minifier for game scripts and the text minifier for plain text.
How much do you save?
Savings depend on how the source was written. Well-commented, indented JavaScript often shrinks by 30–60% before compression; pretty-printed JSON loses the indentation, which can be a third of its size. On the web, servers also compress responses with gzip or Brotli, which reduces the benefit somewhat, but minified files still compress to smaller sizes than unminified ones, and the browser has less to parse.
Workflow tips
- Keep the readable source. Minify as a build or deployment step, never edit minified files by hand. If you only have a minified file, the matching formatter restores a readable layout (though not removed comments or original names).
- Use source maps in production JavaScript so error messages point to your original code.
- Test after minifying. Code that relies on function names, or inline scripts in HTML, can occasionally behave differently.
- Check the result – minified JSON and XML can be validated with the JSON and XML validators, and a quick diff against a formatted copy confirms nothing changed.
Minifying vs obfuscating vs compressing
Minifying makes code small, obfuscating makes it hard to understand, and compression (gzip, Brotli) makes any file smaller during transfer and is reversed automatically by the browser. They complement each other; none of them makes code secret. All minifiers here work in your browser, so your source code is not uploaded.