Developer tool

Code Minifier and Beautifier

Minify or beautify HTML, CSS and JavaScript in your browser. Shrink files for production or reformat messy code, with size savings shown.

Free, no sign-up. Runs in your browser; nothing is uploaded.

Options

Language
Action

Minify strips comments and whitespace. Beautify uses Prettier, loaded on demand.

Input

Output

How to use the code minifier and beautifier

Make code smaller or readable again

Minified code loads faster; beautified code is easier to read and review. This tool does both for HTML, CSS and JavaScript, and shows how many bytes you saved.

Minify

Choose a language, paste the code and keep Action on Minify.

  • CSS: comments and extra whitespace are removed, the last semicolon in each rule is dropped and zero lengths such as 0px become 0. Strings and url() values are protected.
  • HTML: comments and the whitespace between tags are removed. Content inside pre, textarea and script elements is left exactly as written, and embedded style blocks are minified as CSS.
  • JavaScript: Terser compresses the code and can shorten local variable names. Switch "Shorten variable names" off if you want compression without renaming.

Beautify

Switch Action to Beautify to reformat minified or untidy code with Prettier. Choose two, four or eight space indentation, or tabs. This is ideal for reading a minified file from a third party, cleaning up pasted snippets or checking what a build step produced.

Why the libraries load on demand

Terser and Prettier are large. They are fetched only when you first minify JavaScript or beautify, so the page opens quickly and you only download what you use. After the first load they work offline in the same tab.

Good practice

  1. Keep your source files. Minified output is not meant for editing.
  2. Test after minifying, especially JavaScript that relies on function names or eval.
  3. Combine with compression. Serve files with gzip or Brotli on top of minification for the best results.
  4. Do not minify twice. The second pass saves almost nothing.
  5. Use source maps in real projects so errors in production map back to your original code.

Privacy

Your code never leaves your browser. There is no server step and nothing is logged.

Frequently asked questions

Which tools do the work?

JavaScript is minified with Terser and all three languages are beautified with Prettier. The libraries are loaded only when you first use them, so the page itself stays light.

Will minifying break my code?

The CSS and HTML minifiers are conservative. JavaScript minification can rename local variables; turn off "Shorten variable names" if your code relies on function names or you want a gentler result.

How much will I save?

Typically 20 to 60 percent for CSS and HTML and 30 to 70 percent for JavaScript before gzip. The size panel shows the exact change.

Does the HTML minifier touch pre or script blocks?

No. Content inside pre, textarea and script is preserved exactly, and style blocks are minified as CSS.

Can I use this for production builds?

It is great for one-off files and quick checks. For a real project, run minification in your build tool so it happens on every deploy.

Is my code uploaded?

No. Everything runs in your browser.