Web Development & SEO

HTML/CSS/JS Minifier & Beautifier

This tool shrinks HTML, CSS and JavaScript by removing comments and unneeded whitespace, or re-indents minified code so it is readable again. Minifying never renames variables or reorders code, so the output behaves exactly like the input; the saving is shown as (original bytes − new bytes) ÷ original bytes.

Last updated Reviewed by ToolsPulse Hub

Language
Action
Original size—
Result size—
Difference—
Saved—

How to use the minifier and beautifier

  1. Pick the language of your code: HTML, CSS or JavaScript.
  2. Choose Minify to make it smaller, or Beautify to make it readable. For beautify, pick 2 spaces, 4 spaces or tabs.
  3. Paste your code. The result and the size comparison update as you type.
  4. 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:

CSS: remove comments (except /*! licence */), spaces around { } ; , > and after “:”, and the last “;” before “}”. Spaces inside calc() stay. JS: remove // and /* */ comments, indentation and spaces next to punctuation. Strings, template literals and regex literals are copied untouched, and line breaks are kept so automatic semicolon insertion still works. HTML: remove comments, collapse runs of whitespace, drop gaps next to block elements, and leave <pre> and <textarea> content as is. Saved = (original bytes − result bytes) ÷ original bytes

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.

Frequently asked questions

This tool runs entirely in your browser and is provided as-is. See our terms and privacy policy.