What minifying does
Minifying makes code smaller by removing what a computer does not need: comments, blank lines and extra spaces. Smaller files download faster, which helps page speed and, through it, user experience and search performance. This tool minifies JavaScript, CSS, HTML and JSON and shows how much size you saved.
It strips comments and collapses whitespace. It does not rename variables or restructure code, so the output behaves the same as the input and stays easy to debug when needed. JSON is validated first, so you get a clear message if it is not valid.
How to use it
- Choose the language: JavaScript, CSS, HTML or JSON.
- Paste your code and read the minified output and the percentage saved.
- Copy the result into your build, template or config.
Example
A CSS rule before and after:
/* button */
.btn {
padding: 8px 16px;
color: #fff;
}
→ .btn{padding:8px 16px;color:#fff}When to minify, and when not to
- Do minify files you ship to browsers, as part of a build step. Also enable gzip or Brotli on your server, which saves much more.
- Keep the readable source in version control and publish only the minified copy.
- For heavy-duty JavaScript optimisation, use a build tool that can also shorten names. This tool is for quick, safe size reduction.
- Test the result. A missing semicolon in the original can change meaning when line breaks are removed.
What minifying does not do
Keep these limits in mind:
- It does not make slow code faster. It only makes the file smaller to download.
- It does not hide or protect your code. Minified code can be reformatted easily with a code beautifier.
- It does not combine files. Fewer requests need bundling, which a build tool handles.
- It does not replace compression on the server. Turn on gzip or Brotli as well.
Related tools
- Code Beautifier & Formatter: Format JavaScript, TypeScript, JSON, CSS, SCSS, HTML, Markdown and YAML with the Prettier engine.
- JSON Formatter & Validator: Format, validate, and beautify JSON with clear error messages for developers.
- Diff Checker: Compare two blocks of text and instantly see line-by-line additions, deletions, and unchanged content.
- Base64 Encoder & Decoder: Encode and decode Base64 strings for APIs, data transfer, and debugging.
