About HTML Formatter
The HTML Formatter prettifies or minifies HTML markup. Paste messy or compact HTML and get cleanly indented, readable code. Or minify formatted HTML to remove all unnecessary whitespace, comments, and blank lines for production deployment.
HTML formatting is useful when reviewing HTML from APIs, template engines, or page scrapers, when debugging inline styles and attributes, and when onboarding into an unfamiliar codebase.
Minification reduces HTML file size, which improves page load times and Core Web Vitals scores.
Everything runs in your browser. Your data never leaves your device.
How to Use HTML Formatter
Paste your HTML markup into the input.
Choose Prettify (add indentation) or Minify (remove whitespace).
Set your preferred indentation size (2 or 4 spaces).
Copy the formatted output.
Examples
Frequently Asked Questions
Does it fix invalid HTML?
No — it formats the HTML as-is. Mismatched tags and other errors remain in the output. Consider running your HTML through an HTML validator before formatting.
Does minification remove HTML comments?
Yes — HTML comments (<!-- -->) are removed during minification unless they are conditional comments for IE compatibility.
How much does HTML minification reduce file size?
Typically 5–20% for standard HTML files. Combined with gzip compression at the server level, the reduction is even greater.
Does it format inline CSS and JavaScript?
Basic formatting handles HTML structure. For formatting embedded CSS or JavaScript within the HTML, dedicated CSS and JavaScript formatters provide better results.