HTML Formatter
Reformat HTML markup with consistent, readable indentation.
How It Works
- 1Paste your HTML.
- 2It's reformatted automatically with 2-space indentation.
Features
- Recognizes void elements like <br> and <img>
- Instant formatting
Privacy
All processing happens instantly in your browser. Nothing you enter is ever sent anywhere.
About HTML Formatter
HTML documents can technically be written as one continuous line, and minified or auto-generated HTML — from a build tool, a CMS, or copied from 'view source' on a minified page — often is. A formatter reintroduces structure by inserting line breaks and consistent indentation based on element nesting, so it's clear at a glance which tags are children of which, and where one element ends and another begins.
This is useful whenever you need to actually read HTML rather than just render it — debugging a layout issue by inspecting markup, reviewing HTML generated by a template engine or scraping script, or cleaning up markup before including it in documentation or a code sample.
Because HTML allows self-closing and void elements, like <br>, <img>, and <input>, which never have a closing tag, alongside elements that always require one, correctly inferring indentation depends on recognizing which is which — treating a void element as if it needed a closing tag would throw off the indentation of everything that follows it. This tool accounts for the standard list of void elements when computing structure, but it reformats markup as given and doesn't validate whether the HTML is well-formed to begin with.