HTML / XML Formatter & Minifier
Guide: HTML Entities, Formatting and Minifying Explained
Nothing you enter or choose here leaves your device. This tool runs in your browser.
Before and after
Markup copied from a page source or generated by a script often comes as one long line. Here's a small example and what formatting makes of it:
<div><p>Hello <b>world</b></p><ul><li>One</li><li>Two</li></ul><img src='a.png'></div>
<div>
<p>
Hello <b>world</b>
</p>
<ul>
<li>
One
</li>
<li>
Two
</li>
</ul>
<img src='a.png'>
</div>Tags are indented to show nesting. The bold tag stays inside its line of text, because it's an inline tag, and the image is left as a single void tag with no closing partner.
HTML mode or XML mode
| HTML mode | XML mode | |
|---|---|---|
Void tags like br and img | Understood, no closing tag needed | Must be self-closing as written |
Inline tags like b and a | Kept in the line of text | Treated as blocks |
| Use for | Web pages and templates | Feeds, sitemaps, SVG, config files |
What formatting never touches
- Text inside
preandtextareais kept exactly as written, since spaces matter there. - Script and style blocks are re-indented but their contents aren't rewritten.
- The page looks the same afterward. Only the white space between tags changes.
There is one thing to know about inline content. Whitespace between inline tags can show on the page as a space, so adding or removing it can change how things sit. In normal text that doesn't matter. In layouts where inline blocks sit side by side, a stray space can open a gap, so check the result visually.
Minify for production
Minify strips comments, line breaks and extra spaces between tags to make the smallest file. Conditional comments and the contents of pre and textarea are kept. For a typical page, the saving is a few percent, and much less than compression on the server gives, so treat it as a small extra.
Finding mistakes by formatting
- Format the markup. A missing closing tag makes everything after it drift to the right.
- Look for a list item or paragraph that's indented more than its neighbors.
- Check that each opening tag has a partner at the same depth.
- In XML mode, a broken file will show where the structure stops making sense.
The tool only changes layout; it doesn't fix invalid markup. Your code stays in your browser. For styles, use the CSS minifier, and for script, the JS minifier. To go from a page to plain notes, try HTML to Markdown, and the guide on HTML entities, formatting and minifying covers more.
When to choose which indent
Two spaces is the common choice for HTML because nested markup gets deep quickly, and four spaces can push the code off the edge of the screen. Pick one and use it everywhere in a project. If your team uses tabs, choose the tab option so the output matches the files already in your repository, and pull requests show only real changes and not whitespace noise.
Written by Akinrinmade Michael · Updated October 24, 2026
How to use
- 1Choose HTML or XML, then Format or Minify.
- 2Paste your markup into the input box.
- 3Pick the indentation you prefer.
- 4Click Copy output.
Frequently asked questions
Does formatting change how my page looks?
Not in normal cases. It only changes whitespace between tags. Content inside <pre> and <textarea> is left exactly as written, and script and style blocks are only re-indented.
What does minifying remove?
Comments, line breaks and extra spaces between tags. Conditional comments, and everything inside <pre> and <textarea>, are kept.
What is the difference between the HTML and XML modes?
HTML mode knows about void tags such as <br> and <img> and keeps inline tags like <b> and <a> inside the line of text. XML mode treats every element as a block and keeps self-closing tags as written.
Is my markup uploaded?
No. Everything happens in your browser.
Read the guide
Learn how this works and how to get the most from it.
Web & SEO
HTML Entities, Formatting and Minifying Explained
When to escape characters in HTML, how formatting and minifying differ, and how much minifying HTML, CSS and JavaScript really saves.
3 min read
Related tools
CSS Minifier & Beautifier
Compress CSS to save bytes, or format it so it is easy to read.
HTML to Markdown Converter
Convert HTML or pasted web content into clean Markdown.
Markdown Previewer
Write Markdown and see a live formatted preview side by side.
XML ⇄ JSON Converter
Convert XML to JSON and JSON to XML, keeping attributes and lists.