Standard

HTML Formatter

Pretty-print messy or minified HTML with proper indentation.

Advertisement

About this tool

This uses the browser's own HTML parser (DOMParser) to build a real DOM tree from your markup, then writes it back out with indentation. Block elements such as <div>, <section> and <ul> each get their own line, while inline content (text with <b>, <a> or <span>) is kept together on one line, because splitting a sentence across lines would add visible spaces in the page.

The doctype, comments and boolean attributes such as disabled and required are kept as written, and <pre>, <script>, <textarea> and <style> content is copied exactly. Because it's a real browser parser, broken or unclosed markup is corrected the same way a browser would correct it, so the output is equivalent to how a browser understands your page rather than a byte-for-byte copy.