Code Minifier & Beautifier — HTML, CSS, JS
Make your code smaller for faster pages, or neater for easier reading — free, in your browser, with nothing uploaded. Paste HTML, CSS or JavaScript, then click Minify to strip comments and unneeded whitespace, or Beautify to add line breaks and indentation. You will see the character count before and after, and exactly how much you saved. Minifying is a quick win for page speed: smaller files download faster and cost less bandwidth. Beautifying is the reverse: it turns a single compressed line back into readable, indented code you can actually debug. Your code never leaves your device.
// or /* */ inside strings, template literals, or regular expressions, and it does not rename variables. Always test minified output before deploying, and keep your original file.Your Code Results
Output
—
How to Use This Minifier & Beautifier
- Pick a language tab. Choose HTML, CSS or JavaScript. Your code for each tab is kept separately, so switching tabs will not lose what you typed.
- Paste your code. Paste it into the input box, or click “Load sample” to try the built-in example for that language.
- Click Minify or Beautify. Minify strips comments and extra whitespace to shrink the file. Beautify adds line breaks and indentation so you can read it. The result appears in the output box with character counts before and after.
- Copy or download the result. Use “Copy output” to paste it into your editor, or “Download output” to save it as a .html, .css or .js file. Test minified JavaScript in your browser before putting it live, because of the pattern-based limits noted above.
Worked Example
Take the HTML sample <div> <p>Hi</p> </div> — 26 characters including the leading, trailing and double spaces. Click Minify and it becomes <div><p>Hi</p></div>, which is 20 characters: the comments rule does not apply here, but the whitespace between tags and the extra spaces are removed. That is 6 characters saved, or 23.1% smaller. The same tool on the CSS sample body { color: red; /* note */ margin: 0; } (48 characters) produces body{color:red;margin:0} (24 characters, 50% smaller), and on the JavaScript sample function add( a, b ) { // sum return a + b; } (55 characters) it produces function add(a,b){return a+b;} (30 characters, 45.5% smaller). On a real file the saving is usually smaller, because real files are less padded than these samples — but every byte saved is a byte your visitors do not have to download.
Frequently Asked Questions
Is this minifier safe to use on production code?
It is safe for ordinary HTML and CSS, and for simple JavaScript, but it is a simple pattern-based minifier, not a full parser. It can break JavaScript that contains // or /* */ inside strings, template literals or regular expressions. Always test the minified output before deploying it, and keep your original file.
What exactly does the minifier remove?
For HTML it removes comments and whitespace between tags. For CSS it removes comments, spaces around symbols and the last semicolon in a rule. For JavaScript it removes block and line comments and unnecessary spaces around operators and punctuation. It never renames variables or changes your logic.
What does the beautifier do?
The beautifier adds line breaks and indentation so nested code is easy to read: HTML tags are put on separate lines and indented by nesting depth, CSS rules are split onto lines and indented inside braces, and JavaScript is indented by brace depth. It is a basic formatter, not a full code formatter, so very complex code may need manual tidying.
Does my code leave my browser?
No. All minifying and beautifying runs in JavaScript on your own device. Your code is never uploaded to a server, stored, or shared with anyone.
How much smaller does minified code get?
It depends on how much whitespace and how many comments the original has. A small hand-written snippet can shrink by 20 to 50 percent. For example, the HTML sample ' <div> <p>Hi</p> </div> ' is 26 characters and minifies to '<div><p>Hi</p></div>' at 20 characters, saving 23.1 percent. Real-world files usually save less because they are already compact.