Paste HTML to indent it neatly, one tag per line, or minify it for production. Tag mistakes are pointed out by line and column, and nothing leaves your browser.
Runs in your browser; your code is never uploaded.
How to use it
Paste your HTML or open an .html file.
Choose Beautify, then the indent and whether attributes stay on the tag's line or go one per line; or choose Minify.
Copy the result or download it. A tag problem, if there is one, shows below with the line marked.
What each mode does
Beautify puts block elements (<div>, <ul>, <li>, <head>…) on their own lines, indented by depth, and keeps short inline runs like <p>Hi <b>there</b></p> together.
Minify removes comments (IE conditional comments stay), turns runs of spaces and line breaks into one space, and drops the whitespace next to block-level tags, where browsers don't show it.
Example
The one-line page loaded above (393 bytes) comes out as 24 indented lines: <head> and <body> inside <html>, the two list items on their own lines, the navigation links kept together on one line, and the script indented inside its <script> tag. Minify that tidy version and it goes back to a single line of 395 bytes; the script keeps its spaces because Minify doesn't touch code inside <script>.
Beautifying uses the open-source js-beautify library (MIT licence); the minifier and tag check are our own. The same engine runs our CSS and JavaScript formatters.
Frequently asked questions
Will beautifying change how my page looks?
Almost never. Only whitespace between tags changes, and inline elements such as <a>, <b> and <span> stay on their line, so the spaces between words are kept. Text inside <pre> and <textarea> is left exactly as it is.
Does it fix broken HTML?
It lays out what you give it and points to the first tag problem: a closing tag with no opening tag, tags closed in the wrong order, or an element that's never closed. Fix that line and the warning goes. End tags HTML lets you leave out, such as </p>, </li> and </td>, aren't reported.
How much smaller does minified HTML get?
It depends on how much indentation, line breaks and comments the file has, since those are what go: the beautified example on this page shrinks from 514 to 395 bytes (23%). Servers usually compress pages with gzip or Brotli as well, and the two savings add up.
Does it format the CSS and JavaScript inside the page?
Beautify indents the code inside <style> and <script> with the same settings. Minify leaves it as written; use the CSS minifier and the JavaScript minifier for those.
Is my HTML uploaded?
No. The formatter runs in your browser tab, and nothing you paste is sent to a server or opened as a web page.