What is code minification?
Code minification removes the characters that a browser does not need: spaces, line breaks and comments. The code works the same, but the file is smaller and loads faster. Beautification does the opposite. It adds indentation and line breaks so that you can read minified code.
How to use the code minifier
- Select the language: HTML, CSS or JS.
- Paste your code, or click Sample.
- Click Minify to make the code smaller, or Beautify to format it.
- Check the size saving in the status bar, then click Copy.
How much smaller does minified code get?
It depends on how the code was written. Code with many comments and deep indentation often gets 20% to 40% smaller. Code that is already compact gets less. Your server can also compress files with gzip or Brotli, and minified code compresses a little better.
Frequently Asked Questions
What does a minifier remove?
Spaces, line breaks and comments that the browser does not need. The code does the same thing after minification.
What does Beautify do?
It adds indentation and line breaks to minified or messy code, so that you can read and debug it.
Which languages does this tool support?
HTML, CSS and JavaScript. Select the language in the toolbar before you click Minify or Beautify.
Does the HTML minifier keep conditional comments?
Yes. It removes normal HTML comments but keeps conditional comments such as <!--[if IE]>. It also removes the spaces between tags. It does not inline external CSS or JavaScript files.
Is my code sent to a server?
No. Minification and beautification run in your browser. Your code stays on your device.