HTML formatter
Re-indent tangled HTML so its structure is visible again.
How to use
- Paste your HTML into the input box.
- Choose Format to re-indent or Minify to strip inter-tag whitespace.
- Copy the result — script/style/pre contents are untouched either way.
Frequently asked questions
Will it repair broken HTML?
No. It re-indents what is there without validating; a missing closing tag shows up as obviously wrong indentation, which is often exactly how you find it.
What happens to my inline JavaScript and CSS?
The contents of <script> and <style> are preserved byte-for-byte. Use the CSS formatter separately for the styles.
Why are <br> and <img> not indented like other tags?
They are void elements — they cannot contain children, so the formatter correctly treats them as self-contained rather than opening a new level.
About this tool
HTML copied from a browser's view-source, generated by a CMS, or passed through several hands tends to arrive as a wall of tags. The formatter rebuilds the indentation from the tag structure: each nested element steps in two spaces, void elements like <br> and <img> do not create bogus nesting, and the contents of <script>, <style>, <pre> and <textarea> are preserved verbatim rather than mangled. Comments and the doctype stay on their own lines. Minify mode strips the whitespace between tags for embedding or size comparison. Structural formatting only — it will not fix unclosed tags, but it will make them easy to spot.