How to use HTML Formatter
- Paste your HTML into the input box, or click Open a file to load an .html file.
- Choose 2 spaces, 4 spaces or a tab for indentation, and whether to wrap long lines.
- Read the formatted HTML in the output box.
- Click Copy or Download to save formatted.html.
Features
- Indents nested elements with 2 spaces, 4 spaces or tabs
- Optional line wrapping at 80 or 120 characters
- Keeps the content of <pre> and <textarea> as written
- Works on full pages or fragments
- Runs in your browser, so the HTML is never uploaded
Supported formats and limits
- Maximum input: 10,000,000 characters
Examples
| Input | Result |
|---|---|
| <div class="card"><h2>Title</h2><p>Some <b>bold</b> text.</p><ul><li>One</li><li>Two</li></ul></div> | <div class="card"> <h2>Title</h2> <p>Some <b>bold</b> text.</p> <ul> <li>One</li> <li>Two</li> </ul> </div> |
Limitations
- The formatter changes layout only. It does not fix invalid HTML, close missing tags or validate the markup.
- Whitespace is significant in some places, such as between inline elements, so formatting can occasionally change how text is spaced on screen.
- Embedded CSS and JavaScript inside the page are indented but not reformatted in depth.
Learn more
Browsers do not care how HTML is laid out: the same page can be written on one line or spread across hundreds. People do care. Indentation makes it easy to see which elements are inside which, to spot a forgotten closing tag and to review changes.
Minified HTML, produced by build tools to save bytes, is especially hard to read, and formatting it is often the first step when you need to understand a page you did not write, for example while debugging a template or an email.
Formatting works on the text of the markup. It does not parse the page the way a browser does, so it cannot repair errors. Whitespace inside <pre> and <textarea> elements is meaningful and is left alone, while whitespace between inline elements such as <span> or <a> can affect how words are spaced, which is worth remembering when comparing the result with the original.
Frequently asked questions
Does formatting change how the page looks?
Usually not, but in HTML spaces between inline elements can matter, so check the result in a browser if exact spacing is important.
Can it fix broken HTML?
No. It re-indents what you give it. Use an HTML validator to find structural errors.
Can I format a fragment instead of a full page?
Yes. A snippet such as a single <div> works as well as a complete document.
Is my HTML uploaded?
No. Formatting runs in your browser.
Sources
Last reviewed: September 30, 2026