How to use the minifier and beautifier
- Pick the language of your code: HTML, CSS or JavaScript.
- Choose Minify to make it smaller, or Beautify to make it readable. For beautify, pick 2 spaces, 4 spaces or tabs.
- Paste your code. The result and the size comparison update as you type.
- Copy the output or download it with the right file extension.
What minifying removes, and why it is safe
Browsers ignore comments and most whitespace, so deleting them changes the file size but not the behaviour. This tool takes a cautious approach for each language:
Worked example
A small CSS rule set with a comment, spaced colons and line breaks is 122 B. Minified, it becomes .btn{color:#ffffff;padding:8px 16px}.btn:hover,.btn:focus{background-color:#0b6e5f}, which is 83 B. That is 39 bytes, or 32.0%, less to download, and the page looks identical.
Minify versus compress
Minifying and server compression (gzip or Brotli) work together. Compression already squeezes repeated whitespace, so the real-world gain from minifying is smaller than the raw byte count suggests, but it is still worth having, especially for JavaScript, where removed comments and shorter files also parse faster. Advanced tools such as Terser go further by shortening variable names and removing dead code; they need a full parser and a build step. This tool deliberately avoids those changes so you can trust the output without testing it.
Beautifying uses the open-source js-beautify library, loaded from this site only when you choose Beautify.
Test after you minify
Even a cautious minifier works only on the text it is given. If the original JavaScript relied on a missing semicolon at a line join, or if CSS contains a hack for an old browser, check the page once with the minified file before replacing the original. Keep the readable version in your project and treat the minified copy as a build output.
Key features
- Three languages in one place, with minify and beautify for each.
- Byte counts and percentage saved, measured in UTF-8.
- Inline <style> and <script> blocks in HTML are minified too.
- Keeps licence comments that start with
/*!. - No upload: private code never leaves your device.
Practical use cases
Small sites without a build tool. Paste a stylesheet or script before uploading it to a static host or a CMS theme.
Debugging third-party code. Beautify a minified script or stylesheet from a plugin to find the rule or function causing a problem.
Email templates. Some email clients clip messages above about 100 KB. Minifying the HTML can keep a long newsletter under that limit.