HTML Formatter & Beautifier Online
Paste minified or messy HTML into the input box, then click Format to re-indent it with each element on its own line, or Minify to strip the whitespace back out. It understands void tags like <br> and <img>, leaves <script>, <style>, and <pre> content untouched, and runs entirely in your browser.
Your HTML is formatted locally in your browser and never sent to a server.
HTML rules a formatter has to respect
Treating HTML as XML, with a closing tag for every opening one, produces wrong indentation. Bundlers such as webpack and Vite emit production pages as one line, so these cases show up whenever built markup is pasted back for reading.
| Rule | Elements | If a formatter ignores it |
|---|---|---|
| Void, never closed | br, img, hr, input, meta | Every following element lands one level too deep |
| Closing tag optional | li, tr, td, option | In <li>one<li>two the second item gets nested inside the first, while a browser ends the first item where the next begins |
| Raw text content | script, style, pre, textarea | A less-than comparison in JavaScript is read as a tag and the code gets reflowed |
Frequently asked questions
- Can it fix broken or unclosed HTML?
- No. It still formats markup with missing closing tags and lists what looked off, such as Unclosed tags: <span>, <div>, but it does not rewrite your HTML to make it valid. Use it to read and tidy, not to repair.
- What indentation does the HTML formatter use?
- Two spaces per nesting level, with no option to change it. Each child sits two spaces deeper than its parent element.
- Why are b and span tags left on the same line?
- The browser shows a line break between inline elements and text as a space. So the formatter keeps text with a, b, code, em, i, span or strong on one line, and only block elements such as div, p, ul and li get lines of their own.