HTML Formatter
Beautify messy HTML with proper indentation. Paste HTML that is all on one line — copied from a minified page or a template — and press Format. The result is neatly indented so you can read the structure: which tags are inside which, and where each element starts and ends.
How to use this converter
Paste your HTML and press 'Format HTML'. The output is indented by nesting level. Use the indent selector for 2 or 4 spaces, or tabs. Press Copy to copy the formatted code.
Formula
Formatting works by nesting: every opening tag increases the indent for the lines inside it, and every closing tag decreases it.
text
text
indented once, thenand
This is a basic beautifier, not a full HTML parser: it indents by tag nesting and handles the common tags correctly. It does not validate your HTML or fix broken tags — for that, use a validator. But for reading minified code, it is exactly what you need.
Before and after
| From | Equals |
|---|---|
| Before | Hello |
| After | newline Hello (indented) newline |
| Comments | are kept in place |
Frequently asked questions
How do I format HTML?
Paste it above and press 'Format HTML'. The output is indented by nesting level — 2 spaces by default, or 4 spaces or tabs if you prefer.
Does it fix broken HTML?
No — this is a formatter, not a validator. It indents what you paste; it does not add missing closing tags or fix mistakes.
What about <script> and <style> blocks?
Their contents are left as they are — the formatter indents the tags around them but does not reformat JavaScript or CSS inside.
Is my code sent anywhere?
No. The formatting runs entirely in your browser — your code never leaves your device.
Can it minify HTML too?
Not on this page — use the CSS minifier for CSS. For HTML, removing whitespace by hand is risky, because spaces inside text matter.