HTML Formatter & Minifier
Format (beautify) HTML code or minify it for production code.
About HTML Formatter & Minifier
Paste HTML and this tool formats it with four-space indentation, or squeezes it into a smaller file. Formatting turns a messy or single-line page into properly indented code that is easy to read and edit. Minifying removes comments and the whitespace between tags to reduce the size.
The minifier is careful with content where whitespace counts: pre, textarea, script and style blocks are left unchanged, and Internet Explorer conditional comments are kept. It is a basic minifier, though. It does not minify the CSS or JavaScript inside your page, and removing whitespace between inline elements can change the spacing in the rendered page slightly, so check the result.
Formatting uses the js-beautify library, which is loaded from a CDN. Everything runs in your browser, so your code is not uploaded.
Who uses it and when
Cleaning up markup
Re-indent HTML from a page builder or a copy and paste.
Reading source code
Format one-line HTML to understand its structure.
Smaller files
Minify static HTML or an email template.
Sharing code
Paste tidy HTML into docs and tickets.
Why use this HTML Formatter & Minifier
Beautify and minify HTML in your browser.
Format
Clean four-space indentation.
Minify
Removes comments and extra whitespace.
Protects pre and script
Whitespace-sensitive blocks are left alone.
How it works
Paste your HTML
Use the input box.
Format or Minify
Choose the action.
Copy the result
Use Copy.
Frequently asked questions
Does minifying break my page?
It should not, but removing whitespace between inline elements can change spacing. Test the result.
Does it minify CSS and JavaScript too?
No. Style and script blocks are left unchanged.
Does it fix invalid HTML?
No. It re-indents what you give it.
Is my HTML uploaded?
No. It runs in your browser.