Boneyard Tools

HTML Formatter and Beautifier

Paste minified or messy HTML to indent it cleanly. Each nested element is pushed one level deeper, void tags like img and br stay flat, and the contents of pre, script and style are left exactly as written.

How to format HTML

  1. Paste your HTML into the editor.
  2. Pick an indent size of 2 spaces, 4 spaces, or a tab.
  3. Copy the formatted markup or download it as an .html file.

Examples

Indent a nested list

<ul><li>One</li><li>Two</li></ul>
<ul>
  <li>One</li>
  <li>Two</li>
</ul>

Frequently asked questions

Is my HTML sent to a server?

No. Formatting happens entirely in your browser, so your markup never leaves your device.

How does the indentation work?

Every element adds one level of indentation to its children. Void elements such as img, br, input and hr are self-closing, so they never indent the tags that follow them.

Will it break my <pre>, <script> or <style> blocks?

No. The contents of pre, script, style and textarea are whitespace-sensitive or non-HTML, so they are copied through verbatim and never reindented.

Does it minify HTML as well?

This tool beautifies and indents HTML for readability. It collapses extra whitespace between tags but does not strip markup. For the smallest output, use a dedicated minifier.

Can I change the indent character?

Yes. Choose 2 spaces, 4 spaces, or a tab. The same options are available through the API using the indent field.

Related tools