HTML Formatter

Paste minified or messy HTML and get properly indented markup back, with the nesting visible at a glance. The tricky parts are handled rather than ignored: inline elements stay inline, so a paragraph containing a link or some bold text remains one readable line instead of being exploded across four; an element that holds only text keeps its closing tag on the same line; and the contents of pre, textarea, script and style are preserved exactly, because whitespace in those is significant and collapsing it changes what the page renders. Spaces around inline tags are carried through explicitly too — losing them runs words together, which is a formatter silently editing your content rather than its layout. Void elements are left unclosed. It runs entirely in your browser.

How each kind of element is treated

ElementTreatment
div, section, ul, liOwn line, contents indented
p with only textStays on one line, closing tag included
a, span, strong, emInline — no forced break, spaces preserved
img, br, input, metaOwn line, never given a closing tag
pre, textareaContents preserved exactly
script, styleContents preserved, not reindented
<!-- comment -->Own line

When to use it

  1. Make minified markup readable so you can find the element you need.
  2. Reformat HTML copied out of devtools or a page source.
  3. Tidy template output before committing it.
  4. Inspect the structure of a page you did not write.
  5. Compress markup back down after editing.

How to Use

  1. Paste your HTML, minified or otherwise.
  2. Choose an indent size, or tabs.
  3. Read the formatted markup, or flip to minify to go the other way.
  4. Copy or download the result.

Features

  1. Nesting indented by depth, configurable size or tabs
  2. Inline elements kept inline, text-only elements on one line
  3. pre, textarea, script and style preserved verbatim
  4. Spaces around inline tags preserved so words do not run together
  5. Void elements left unclosed, each on its own line
  6. Comments kept on their own line
  7. Minify direction included
  8. 100% client-side — unpublished markup stays private

FAQs

Will it change what my page renders?

It should not. Inline spacing is preserved, and pre, textarea, script and style bodies are left byte-for-byte. Those are the three places where reformatting HTML can genuinely alter output, and each is handled deliberately.

Why do some tags stay on one line?

Because they are inline elements, or because the element contains only text. Breaking a paragraph with a link inside it across four lines makes it less readable, not more, and in some contexts adds rendered whitespace that was not there before.

What happens to script and style blocks?

Their contents are preserved exactly as written and not reindented. Formatting JavaScript or CSS correctly is a different job — use the dedicated JS or CSS formatter for those.

Are void elements closed?

No. Elements such as img, br, input and meta have no closing tag in HTML, and adding a self-closing slash is unnecessary. They are emitted exactly as given, each on its own line.

What is the difference between this and the HTML Minifier?

They share the same engine. This page is focused on making markup readable; the minifier focuses on making it small, with compression levels, batch file handling and analysis alongside.

Is my HTML uploaded?

No. Formatting happens in your browser. Unpublished pages and markup containing customer data are never sent to a server, logged, or stored.

Technical Details

Before any whitespace is touched, the bodies of pre, textarea, script and style are stashed and replaced with placeholders, because whitespace inside them is significant — collapsing it changes what the page renders or what the script does. The remaining markup is normalised and then walked tag by tag, tracking nesting depth. Three distinctions do the real work. Void elements are never given a closing tag. Inline elements do not force a line break, so a paragraph containing bold text stays on one line rather than being exploded across four. And a closing tag only goes on its own line when the element actually contained block-level children — an element holding just text keeps its closing tag inline, which is the difference between correct output and a paragraph that reads as an opening tag, text, then a stray closing tag on the next line. Spaces that separated text from an adjacent inline element are carried through explicitly, since dropping them runs words together and visibly changes the rendered page. The same engine backs the Beautify tab of the HTML Minifier.

Developer Tools

Developer Tools

  • LLM Token Counter
  • .gitignore Generator
  • Dummy Data Generator
  • RAID Calculator
  • Download Time Calculator
  • JSON Formatter
  • JSON Validator
  • Base64 Encoder / Decoder