HTML Formatter
Paste HTML and get it back with each tag on its own line and nested tags indented. Text and attributes are not changed.
Use the tool
Loading the tool…
About HTML Formatter
Paste HTML that is hard to read and get it back indented, with your choice of 2 spaces, 4 spaces or a tab. You can also wrap long lines at 80 characters or leave them unwrapped.
Worked example
Paste `<div><p>Hello <b>world</b></p></div>`. The output puts each element on its own indented line.
Limits
Formatting does not check the HTML for errors. Test the page in a browser after you change the code.
How to use HTML Formatter
- Paste your HTML.
- Choose the indent and the line width.
- Choose whether to remove comments.
- Copy or download the result.
Good to know
- Only spacing between tags changes. Tags, attributes and text keep their order.
- Content of pre, textarea, script and style is left exactly as written.
- Inline tags such as a, b and span stay inside the line of text they belong to.
- The formatter does not fix broken HTML. It lays out what it finds.
Frequently asked questions
Will it change how my page looks?
It is made not to. It only changes white space, in places where browsers treat white space as one space or none.
Does it fix missing closing tags?
No. Tags without a closing tag are left as they are.
Can I format a full page and a small piece?
Yes. Both work.