HTML Formatter & Beautifier
Paste messy or minified HTML and get it back neatly indented: one element per line, nested tags indented, text and inline tags kept together. Runs in your browser.
How to use the HTML formatter
- Paste your HTML, or click Try an example.
- Pick 2 spaces, 4 spaces or Tab for the indent.
- Click Format HTML, then copy the result or publish it as a link.
What the formatter changes
It puts each block element (div, p, li, section and so on) on its own line and indents it one step deeper than its parent. Text and inline tags like <a>, <b>, <span> and <img> stay together on one line, and a short element such as <li><a href="/">Home</a></li> stays on a single line. The content of <pre> and <textarea> is kept exactly as written, and the code inside <script> and <style> is re-indented as a block without other changes.
Questions
Is my HTML uploaded?
No. It's formatted in your browser. It only leaves your computer if you click Publish this page.
Will formatting change how my page looks?
Usually not. Browsers ignore most whitespace between tags. Two places can change: runs of spaces inside text are collapsed into one, and inline elements written on separate lines can gain a space between them. <pre> and <textarea> are left untouched.
Does it fix broken HTML?
No. It formats what you paste. If a tag is never closed, everything after it is indented one step too deep, which is a quick way to spot the missing closing tag.
Can it un-minify HTML?
Yes. Paste minified HTML from a page's source and it comes back one element per line. To go the other way, use the HTML minifier.
Does it format the CSS and JavaScript inside the page?
It re-indents the code inside <style> and <script> to fit the page, but doesn't reformat the code itself.