HTML Formatter
Paste HTML and get it re-indented and wrapped consistently. Inline CSS and JavaScript inside style and script tags are formatted too.
About this tool
Minified or machine-generated HTML is a single wall of text that is impossible to review. A formatter rebuilds the tree with one element per line and consistent indentation so structure errors — an unclosed div, a table cell outside a row — become visible at a glance. This tool uses Prettier, the same opinionated formatter used in most modern front-end projects, so the output matches what your editor would produce.
Choose two or four spaces or tabs, and a line width of 80, 100 or 120 characters. Prettier respects whitespace-sensitive inline elements, so formatting never changes how the page renders. Everything runs locally; the formatter is loaded on first use.
Frequently asked questions
- Why did formatting fail?
- Prettier needs parseable HTML. The error message points to the line with the problem, usually a stray angle bracket or an unterminated attribute quote.
- Does it format the CSS and JavaScript inside the page?
- Yes. Embedded style and script blocks are formatted with the CSS and JavaScript parsers.
- Can I format a template with Jinja, Blade or PHP tags?
- Template syntax often confuses the parser. Format the pure HTML parts separately.