HTML Formatter
Formats HTML with two-space indentation, handling the parts of HTML that are not XML: void elements like img and br are never closed, script and style contents are preserved exactly, and optional end tags are filled in, so a list written as "li one li two" comes back properly closed. Inline elements stay on the same line as their text. Runs entirely in your browser — nothing is sent to a server.
Formats HTML with two-space indentation, handling the parts of HTML that are not XML: void elements like img and br are never closed, script and style contents are preserved exactly, and optional end tags are filled in, so a list written as "li one li two" comes back properly closed. Inline elements stay on the same line as their text. Runs entirely in your browser — nothing is sent to a server.
Use cases
- Making a minified or machine-generated page readable
- Tidying a fragment copied out of a template
Examples
Nested markup
<div><p>Hello <b>world</b></p></div>
<div> <p>Hello <b>world</b></p> </div>
FAQ
Is my markup sent to a server?
No — this tool runs entirely in your browser.
Why is my paragraph not broken across lines?
Inline elements such as b, a, and span stay with their surrounding text. Breaking them onto separate lines would change how the text renders in the browser.
What happens to script and style blocks?
Their contents are left exactly as written, since re-indenting code or CSS inside them risks changing what it means.