Skip to content

HTML Formatter

Re-indent HTML without breaking whitespace-sensitive elements.

Quick Tool Overview

The HTML Formatter re-indents markup while keeping inline elements on one line and leaving pre and script contents alone — so a sentence containing a link is not chopped into three, and whitespace that is content survives.

What it does
Re-indents HTML without changing how it renders
You give it
A page, a fragment, or markup from dev tools
You get back
Readable HTML, plus any assumptions it had to make
Best for
Reading minified markup and tidying templates
Developer Tools Free, unlimited use No sign-up Runs in your browser

About the HTML Formatter

Paste HTML and get it back readable: one block element per line, children indented under their parent, and inline elements kept on the line they belong to so a sentence containing a link does not get chopped into three.

The parser is the forgiving kind, because real HTML is. Unclosed paragraphs and list items, unquoted attribute values and stray closing tags are all handled the way a browser handles them, and anything it had to assume is reported. Script and style contents are indented but not reformatted, and boolean attributes stay bare rather than being expanded into attribute="attribute".

Key features of the HTML Formatter

Inline elements stay inline

A line break between two inline elements adds a space, so they are deliberately kept together rather than each given a line.

pre and script preserved

Whitespace inside pre is content. Script and style bodies are indented as blocks but never reformatted.

Forgiving like a browser

Unclosed paragraphs and list items, unquoted attributes and stray closing tags are all handled the way a browser handles them.

Assumptions reported

Anything the parser had to infer is listed, so malformed markup is visible rather than silently corrected.

Boolean attributes left bare

disabled stays disabled rather than being expanded to disabled="disabled", which is the modern convention.

How to use the HTML Formatter

  1. 1

    Paste your HTML

    A full page, a fragment, or something copied out of developer tools.

  2. 2

    Choose the indentation

    Two spaces, four spaces or a tab.

  3. 3

    Check the warnings

    Anything the parser had to assume — an unclosed tag, a stray closer — is listed.

  4. 4

    Copy the result

    Take it to your clipboard or download it as an .html file.

Frequently asked questions

Whitespace between block elements is insignificant, so no. Inline elements are deliberately kept on one line, because adding a line break between two inline elements does add a space.

Reviews of the HTML Formatter

What people who use the HTML Formatter think of it. Reviews come from visitors and are posted as written.

No ratings yet

Yours would be the first.

  • 5 0 reviews rated 5 stars
  • 4 0 reviews rated 4 stars
  • 3 0 reviews rated 3 stars
  • 2 0 reviews rated 2 stars
  • 1 0 reviews rated 1 star

Write a review

Used this tool? Your rating helps the next person decide.

Your rating

Plain text only — links, email addresses and HTML are not accepted. Your name and review are shown publicly; nothing else is collected. See the privacy policy.

0 reviews

Newest first

No reviews yet

Be the first to rate the HTML Formatter. It takes half a minute and no account.

Write the first review

More developer tools