Format and beautify HTML

Re-indent messy or minified HTML. Choose the indent and line wrap. Runs in your browser.

How it works

  1. Paste your HTML
  2. Choose indent, wrap and blank lines
  3. Copy the formatted HTML

What the formatter changes

The page changes only the white space between tags. Each block element, such as div, ul, li and p, starts on its own line and is indented one level deeper than its parent. Inline elements such as b, i, a and span stay inside their line of text. The words, attributes and tags themselves are not edited, reordered or removed. Choose 2 spaces, 4 spaces or a tab for each level. Text inside script and style tags is laid out as JavaScript and CSS with the same indent. Content inside pre and textarea tags is left as you typed it, because white space matters there.

Wrap and blank lines

Wrap lines at sets a maximum line length in characters. A long paragraph is broken at a space before it passes that number, and the continuation is indented. A single word or a long attribute value is never cut, so such a line can stay longer. Type 0 to turn wrapping off and keep each line as long as it is. The number box accepts 0 to 500. Keep blank lines is on by default: a run of several blank lines becomes one blank line, so the gaps you left between sections survive. Turn it off and all blank lines are removed.

What it does not do

It does not check your HTML and it does not repair it. A missing closing tag, a tag opened in the wrong place or an attribute without its closing quote is neither fixed nor reported, and the layout around the mistake may look odd. It does not render the page, so a script tag in your input never runs and a linked stylesheet is never fetched. It does not shorten HTML either: it only adds line breaks and indents. Tag names, attribute order, quotes and comments stay as you wrote them.

Limits and where it runs

The work happens in this tab. The text is not sent to a server, not saved and not put in the page address. Only your choices, such as the 4 space indent, are remembered in this browser. The formatting code is a separate download that loads when the page opens, so the result appears after a short moment on the first visit. Up to 500,000 characters are handled. Above 100,000 characters the result follows your typing after a short pause, and a very large document can take a few seconds. Longer text shows a message asking you to split it.

Frequently asked questions

Does it fix or validate my HTML?

No. It only re-indents. A missing closing tag, a tag opened in the wrong place or an attribute without a closing quote is not repaired or reported, and the layout around it may look odd. Use a validator when you need to find mistakes.

Is my HTML rendered or run?

No. The text is treated as plain text and laid out. Nothing is shown as a web page, so a script tag in your input does not run and a stylesheet link is not fetched.

Why is one line still longer than my wrap length?

Wrapping happens only at spaces between words. A long URL, a single long word or a long attribute value has no space to break at, so that line stays whole. Raise the wrap length or set it to 0 if you prefer.

Can I get minified HTML from this page?

No. This page only adds line breaks and indents. To shorten a text, remove the extra spaces yourself, or use the remove extra spaces tool for plain text.

Is there a size limit?

Yes, 500,000 characters per paste, which is roughly a 500 KB file. Over that limit the page asks you to split the HTML into parts.