Remove whitespace and comments from HTML, keep pre and scripts safe
HTML Formatter
Make tangled or one-line HTML readable again with consistent indentation, without changing the page.
Loading tool…
How to use html formatter
Paste HTML or open an .html file.
Pick the indent size and how long a line may get before an element is split across lines.
Optionally format the CSS inside style blocks too.
Copy or download the formatted HTML once the check passes.
What this tool does
- Gives each block element its own indented line and keeps short elements with only text, such as a heading or a link, on one line.
- Keeps inline elements like a, strong and span inside the surrounding text so no extra spaces appear on the page.
- Copies the content of pre and textarea exactly and re-indents script and style blocks as a whole.
- Understands optional end tags, so lists and tables written as <li>One<li>Two indent correctly.
How the result is verified
The output is read again and compared with the input: the same tags with the same attributes, the same comments and the same words of text must appear in the same order, or the download stays off.
Frequently asked questions
Can formatting change how my page renders?
The tool only adds line breaks and indentation between block elements, where browsers ignore whitespace, and leaves text runs with inline tags on one line. Content inside pre and textarea is never touched.
Does it work on SVG and XML?
SVG markup formats well because its elements are treated as blocks. Other XML usually works too, though the tool does not check XML rules such as matching every end tag.
Is my data uploaded to a server?
No. Everything you drop, paste or type is processed by code running in this browser tab. You can check it yourself: open your browser's developer tools, watch the Network panel, and use the tool. No request carries your data.
Related tools
Beautify minified CSS with clean indentation, selectors and media queries
Edit HTML, CSS and JavaScript and run them live in a sandbox with a console
Paste HTML or open a file and get a PDF with real, selectable text
A split Markdown editor and preview for README files, notes, documentation, and messages, processed locally.