Code minifier and beautifier

This code minifier shrinks HTML, CSS, JavaScript and JSON, and can beautify HTML, CSS and JSON to make them readable again. It shows exactly how many bytes you save.

Processed on this device. Nothing is uploaded.
Loading Code Minifier & Beautifier…

How to minify or beautify code

  1. Choose the language: HTML, CSS, JS or JSON.
  2. Paste your code into Input, replacing the sample.
  3. Click Minify or Beautify, choosing 2 spaces, 4 spaces or tabs for indentation.
  4. Check the size reduction, then Copy or Download the output.

What you can do with Code Minifier & Beautifier

Four languages
Minify HTML, CSS, JavaScript and JSON from one page, with a sample of each language to try first.
Beautify HTML, CSS and JSON
Reformat compressed or messy code with consistent indentation and one rule or tag per line.
Size savings
Shows input and output size with the percentage saved, so you can see the effect of each run immediately.
Safe HTML handling
Leaves <pre>, <textarea> and <script> content untouched, minifies inline <style> blocks and keeps conditional comments.
Conservative JS minify
Removes comments and extra whitespace but keeps line breaks and names, so automatic semicolon insertion can't break your code.
License comments kept
Comments starting with /*! are preserved in CSS and JS, the usual convention for license and copyright notices.

How code minification works and its limits

Minification removes characters that browsers don't need, such as comments, indentation and line breaks, to reduce file size and speed up page loads. Savings vary: hand-written CSS often shrinks by 15 to 30 percent, and heavily commented code by more. Since most servers also apply gzip or Brotli compression, minifying and compressing together give the best result. Beautifying does the reverse, restoring indentation so minified or machine-generated code is readable when you need to debug or edit it.

This tool is deliberately lightweight. The CSS minifier strips comments and whitespace but doesn't merge rules or shorten colors, and the JavaScript minifier removes comments and spaces without renaming variables, which keeps it safe but less aggressive than Terser or esbuild. For production builds, a bundler with a full minifier will squeeze out more bytes. For quick jobs, like an inline snippet, an email template, a CMS field or a one-off stylesheet, a browser tool is faster than setting up a build step.

Frequently asked questions

Is my code uploaded to minify it?

No. Minifying and beautifying run in JavaScript inside your browser, so your source code never leaves your machine. That makes the tool suitable for proprietary code, client projects and anything covered by an NDA.

Can it beautify JavaScript?

Not currently. JavaScript can only be minified here, because reliable JavaScript formatting needs a full parser. For formatting JavaScript, use Prettier in your editor. HTML, CSS and JSON can be both minified and beautified.

Will minifying break my code?

It's designed to be safe. CSS and HTML minification only remove comments and redundant whitespace, script and pre blocks in HTML are left alone, and JS minification keeps line breaks so semicolon insertion still works. Always test minified code before deploying.

What does Remove spaces between tags do?

In HTML mode it deletes whitespace between a closing tag and the next opening tag, saving more bytes. It can change layout where inline elements like links or buttons rely on a space between them, so check the page after using it.

How much smaller will my files get?

It depends on how much whitespace and how many comments your code contains. Typical hand-written CSS and HTML shrink by 15 to 30 percent, and the exact saving is shown after each run. Gzip or Brotli on your server reduce transfer size further.