HTML Formatter
Beautify HTML with clean indentation, including inline CSS and JavaScript.
Runs in your browser
Making HTML readable again
HTML copied from a page's source, an email template or a CMS often arrives on one long line, or with indentation all over the place. That makes it hard to see which tag is inside which, or where a missing </div> broke the layout.
Paste it here and every element gets its own line, indented by how deeply it's nested. Inline <style> and <script> blocks are formatted as CSS and JavaScript, short inline tags like <a> and <em> stay inside their text, and whatever is in <pre> and <textarea> stays exactly as it was, because spaces there show on the page.
How to use the HTML Formatter
Paste your HTML. A whole page or just a fragment. Or load the sample.
Pick the indentation. 2 spaces, 4 spaces or tabs.
Copy the result. The formatted HTML updates as you type.
Tips
- Formatting only changes whitespace between tags, which browsers ignore in most places, so the page looks the same.
- Looking for a missing closing tag? After formatting, the indentation goes wrong right where the tag is missing.
- For XML (sitemaps, SOAP, Android layouts), use the XML Formatter, which also checks that it's well-formed.
Frequently asked questions
Does it fix invalid HTML?
No. It formats what's there and never adds or removes tags, so a missing closing tag stays missing. That's on purpose: it shouldn't change your markup.
Can it minify HTML?
Not yet. Safely minifying HTML means knowing where whitespace matters (inline text, <pre>, inline-block layouts), and a wrong guess changes the page. Your server's gzip or Brotli compression already removes most of the size.
Does it work with Vue or Angular templates?
Plain HTML-style templates like Vue and Angular format well. JSX belongs in the JavaScript Formatter.
Is my HTML uploaded?
No. Formatting runs in your browser.