Usevanta
Developer Tools

HTML Formatter

Turn minified or messy HTML into neatly indented markup that is easy to read and edit. Choose 2 spaces, 4 spaces or tabs, then copy or save the result.

Try it now
Everything runs in this browser. Nothing you enter is uploaded.
2 spaces

Your HTML is formatted as plain text. It is never rendered or run, so scripts and links in it stay inactive. Contents of <pre> and <textarea> are kept exactly as written.

Formatted HTML
Your formatted HTML will appear here...

How to Use the HTML Formatter

  1. Paste your HTML into the input box.
  2. Choose an indentation style: 2 spaces, 4 spaces or tabs.
  3. Check any warnings about unclosed or unmatched tags shown above the result.
  4. Copy the formatted HTML or save it as an .html file.

Example

Input
<div class="card"><h2>Title</h2><ul><li>One</li><li>Two</li></ul></div>
Output
<div class="card"> <h2>Title</h2> <ul> <li>One</li> <li>Two</li> </ul> </div>

About the HTML Formatter

Formatted HTML is much easier to read, review and debug than markup squashed onto one line. Developers use a formatter to inspect minified templates, tidy code copied from a CMS or email builder, or make a snippet readable before sharing it.

Block elements such as div, ul and section are placed on their own lines and indented by nesting level. Short elements that only contain text or inline tags like b, a and span stay on one line. Whitespace between words is collapsed to a single space, while the contents of pre and textarea are kept exactly as written. Script and style blocks are re-indented but their code is not reformatted.

The formatter is forgiving: if a tag is not closed or a closing tag has no match, it still formats what it can and lists a warning. It does not add missing closing tags or validate your HTML against the specification. Your markup is processed as plain text in your browser. It is never rendered, so scripts, styles and links inside it do not run.

Frequently Asked Questions

Does the formatter change how my page looks?

It only changes indentation and line breaks. Because runs of spaces between words are collapsed, whitespace-sensitive layouts can differ slightly; content inside pre and textarea is never changed.

What happens with invalid or incomplete HTML?

The formatter still produces output and shows warnings for unclosed tags, unmatched closing tags and unfinished tags. It does not try to repair the markup for you.

Is it safe to paste HTML that contains scripts?

Yes. The HTML is treated as text only. It is never inserted into the page, so scripts and event handlers in it cannot run.

Can I format the CSS or JavaScript inside my HTML?

Style and script blocks are re-indented to match their position but their contents are not reformatted. Use the CSS Formatter for stylesheets.

Is my code uploaded to a server?

No. Formatting happens in your browser with JavaScript, and this tool does not send your markup to a Usevanta server.