This page puts one tag per line and indents nested elements, turning a compressed HTML string into something you can read. Paste the markup, choose two spaces, four spaces or a tab, and the formatted version appears beside the form. It works on text, so it does not need a server or an account.
The formatting is structural, with a light repair pass. The page closes elements that were left open, drops a closing tag that has no matching element, and reports how many repairs it made. It is still not a validator: it does not check attribute rules, duplicate ids or whether the document is valid against the HTML specification.
What changes in the output
Block-level elements start on a new line, and their children are indented one level deeper. The closing tag returns to the parent's level. Inline elements such as a, span, strong and em stay with the words around them, so a sentence containing a link is not broken across four lines.
The doctype stays at the top and is not indented. The html, head and body elements nest in the usual order. Comments are treated as text and keep their position. The output adds line breaks, so the character count almost always rises even when the input was valid; the stats show both the input and output size.
Attributes are left exactly as written. The formatter does not reorder them, quote an unquoted value or fold a multi-line tag onto one line. If an attribute value contains >, the tokeniser still has to find the end of the tag, so unusual markup is worth checking by eye.
Indentation, wrapping and the raw blocks
Two spaces is a good default for HTML because deep nesting is common. Four spaces makes each level easier to see but pushes content far right in a table-heavy document. A tab is compact, though its width depends on the editor, so a mixed team should agree on one setting.
Wrap long text nodes now works. With it on, any output line longer than 100 characters is broken between words, and the continuation keeps the same indentation. It never splits inside a word, so a long URL or an unbroken token stays on one line. With it off, each run of text stays on a single line, which is the better choice when you want a diff to show one logical change per line.
script, style, pre and textarea are copied without re-indenting, because whitespace inside them can change behaviour. That is the correct decision for code samples and inline scripts, and the line count now counts the physical lines inside those blocks rather than treating the whole block as one. A pre with three lines therefore adds three to the output count, not one.
A worked example
A 31-character snippet with two paragraphs was pasted with two-space indentation. The result was four lines and 38 characters, with each paragraph on its own line.
| Input | Setting | Result |
|---|---|---|
<div><p>one</p><p>two</p></div> | 2 spaces | 4 lines, 38 characters, no repairs |
Unclosed div and stray p, 40 characters | 2 spaces | 6 lines, 53 characters, 2 repairs |
pre with three physical lines, 37 characters | 2 spaces | 6 lines, 44 characters |
| 206-character paragraph | Wrap off / on | 1 line / 3 lines |
The malformed run is the important one. The input was <div><p>open<span>no close</div></p><br>. The pending p is now closed before the div, the stray </p> is dropped, and the stats report two repairs. The output nests correctly instead of putting a closing div above a pending paragraph.
The wrap run shows the new control doing its job. With the option off, the whole paragraph is one 206-character line. With it on, the same text becomes three lines, and no word is broken. The output length is unchanged because wrapping adds only line breaks, not characters.
Raw blocks and inline tags
The raw-block rule protects four elements. A style block keeps its CSS on the lines you wrote; a script keeps its JavaScript; a pre keeps its spaces and newlines; a textarea keeps its default value. Re-indenting any of them would change what the browser sees, so the formatter copies the content between the opening and closing tags as one unit.
Inline elements are kept on the text line for a similar reason. Splitting <p>Formatting runs <strong>in your browser</strong>.</p> across several lines would add whitespace inside the sentence and could change how the text wraps. The formatter therefore keeps the paragraph on one line and only breaks at block boundaries, or at the wrap width when wrapping is on.
When to use it, and what to use next
Use this page when you have a template, an email or a copied snippet on one line and you need to see its structure. It is also useful before a review, because a formatted file makes a diff readable, and the repair pass gives a broken fragment a usable shape. It is less useful as a build step: it does not minify, and its output is larger than the input by design.
For the opposite direction, the HTML minifier removes comments and optional whitespace. For CSS inside a style block, paste the CSS itself into the CSS beautifier, because this page treats the block as raw text. To convert the markup rather than format it, the HTML to Markdown converter is the relevant tool.