tool hub Tool Hub

HTML Formatter

HTML Formatter — runs in your browser. Inputs are not stored.

Runs in your browser No sign-up Free to use


HTML indent

Applies approximate indentation based on tags.

How to use

  1. Paste one-line or messy markup into HTML.
  2. Press Format and check Result, indented two spaces per tag level.
  3. Void elements and comments do not increase depth; they stay at the current line level.
  4. Copy result takes the cleaned markup.
  5. Reset clears input and result together.

Key concepts

The HTML formatter splits tags into tokens, increasing indent on open tags and decreasing on close tags. Images, line breaks, inputs, self-closing tags, comments, and declarations are treated as having no children, so they do not raise depth. It is not a full HTML parser, so mismatched tags still get approximate line breaks. It is useful for unfolding minified component snippets. Text nodes are trimmed and aligned to the current depth, so notes between tags also sit on their own line.

Whitespace between tags is collapsed then re-split, so intentional spaces between inline elements may shrink. Attributes are not sorted and quotes are not normalized—only indentation. Conversion runs in the browser; markup is not sent to a server. It is a good step before a validator, or to tidy tables exported from Excel. Copied output is easier to scan in an editor and to pair with preview.

Example

Format <div><p>hello</p></div>: the next line after open div is p indented two spaces, then hello one level deeper. A void tag such as img does not push the next sibling deeper. Copy the result into your editor.

Related: XML formatter · HTML validator · HTML editor

Frequently asked questions

Does the HTML formatter indent invalid markup?

Yes. It does not block on errors; it only aligns lines by tag tokens, so unclosed fragments still produce output.

How are void tags like img handled?

Void elements, self-closing tags, and comments are treated as having no children, so the next sibling’s depth does not increase.

Can inline spaces disappear after formatting?

Whitespace between tags is collapsed first, so gaps between inline elements may shrink. Recheck layout-sensitive markup.

Are attributes sorted alphabetically?

No. Only indent and line breaks are added. Attribute order and values stay as they were.

Is markup sent to a server?

No. Format and copy run only in the browser. There is no upload button.

Which field does Copy result use?

Only the read-only result field. If input is empty and you have not formatted yet, there is nothing to copy.

HTML Formatter cover image
Your input is not sent to the server and disappears when you close the page.

Last reviewed: 2026-09-04