Skip to content
ToolzKit

Developer

HTML Formatter

Indent HTML markup by nesting depth while preserving pre, script and style content.

Input

Paste HTML

Output

Formatted HTML appears here (as text).

Paste HTML above, or load the example. Output is shown as escaped text, never rendered.

About the HTML Formatter

This tool re-indents HTML markup according to element nesting depth, keeps void elements like img and br inline, and leaves the contents of pre, textarea, script and style tags untouched so whitespace-sensitive code isn't broken. Output is always shown as escaped text, never rendered, for safety.

How to use it

  1. 01Paste your HTML markup into the input panel.
  2. 02Choose an indent width.
  3. 03Review the indented output, shown as plain escaped text.
  4. 04Copy or download the formatted markup as an .html file.

Features

  • Depth-based indentation that tracks opening and closing tags
  • Void elements (img, br, input, hr, and similar) stay on a single line
  • Verbatim handling of pre, textarea, script and style contents
  • Output rendered only as text, never injected into the page

Practical examples

Cleaning up copied markup

Paste HTML copied from a browser's dev tools, which is often minified or inconsistently indented, to get a readable structure for editing.

Limitations

  • This is a tag-based re-indenter, not a full HTML parser, so severely malformed markup (unclosed tags) may indent incorrectly.
  • It does not fix invalid HTML or add missing closing tags.

Privacy

All formatting happens locally in your browser. The output is displayed as escaped text and is never rendered as live HTML, so no user markup can execute.

Read the full privacy policy for how the site as a whole handles data.

Frequently asked questions

Is my HTML executed or rendered anywhere?

No, output is always shown as plain text inside a preformatted block, never injected into the DOM as HTML.

Does it reformat inline styles or attributes?

No, attributes are left exactly as written; only tag nesting affects indentation.

What happens to script and style blocks?

Their contents are preserved verbatim so JavaScript and CSS whitespace-sensitive syntax isn't corrupted.