HTML Formatter
Indent and tidy HTML so nested tags are easy to read, or minify it to remove comments and extra whitespace — right in your browser.
Suggested tools
About HTML Formatter
HTML Formatter re-indents HTML so the structure of nested elements is easy to see, with each block element on its own line and two-space indentation. Use it on minified pages, generated email templates, CMS output or markup copied from browser dev tools.
Minify, on the same page, does the reverse: it removes comments and collapses extra whitespace while leaving <pre>, <textarea>, <script> and <style> content untouched. Everything runs locally in your browser — the text you paste is never uploaded.
How to use HTML Formatter
- Paste your HTML or upload an .html file.
- Press Beautify to format it, or Minify to compress it.
- Copy or download the result.
Key features
- Beautify and Minify in one place
- Formatting by the js-beautify library
- Inline <script> and <style> blocks handled
- No line wrapping, so long lines are never broken mid-text
Example
<ul><li><a href="/">Home</a></li><li><a href="/tools">Tools</a></li></ul>
<ul> <li><a href="/">Home</a></li> <li><a href="/tools">Tools</a></li> </ul>
When to use HTML Formatter
- Reading minified HTML from a website's page source.
- Tidying HTML exported from email builders or page editors.
- Indenting templates before editing them by hand.
Tips and common problems
- Formatting does not fix unclosed tags — validate the structure if layout looks wrong.
- Text inside <pre> is whitespace-sensitive; check those blocks after formatting.
- Use Minify only on the copy you publish.
Frequently asked questions
Indentation between block elements does not affect rendering. Inside inline content, whitespace can matter slightly, so check pages that rely on exact spacing.
No. It formats the markup as it is; unclosed or misnested tags stay that way. Browsers are forgiving, but a validator such as the W3C checker will find structural errors.
Paste one page or file at a time. For build pipelines, use a formatter such as Prettier in your project.