How to format HTML
Paste the code
Paste your HTML or open a file, or try “Example”.
Choose the indent
2 spaces, 4 spaces or Tab, and the line width.
Copy or download
Press “Format”, then copy or download the result.
Options
| Option | Values | Most common |
|---|---|---|
| Indent | 2 spaces, 4 spaces, Tab | 2 spaces in most web projects |
| Line width | 80, 100 or 120 characters | 80; longer lines are wrapped |
Tips
The page looks the same. Prettier knows where whitespace matters (like <b> and <a>), so it breaks lines without adding visible spaces. That’s why you may see a > at the start of a line; it’s on purpose.
Inline CSS and JavaScript. Code inside <style> and <script> is formatted too, with each language’s rules.
Unclosed tags? If the code has a clear error, you get the line, column and reason.
FAQ
What’s the difference between formatting and minifying HTML?
Formatting adds line breaks and indentation so code is easy to read and edit; minifying removes them to make the file smaller for upload. Use the HTML Minifier for the opposite.
Does formatting change the page content?
No. We tested it on dozens of real pages, comparing the elements and text before and after with an independent HTML parser (html5lib): they matched.
Which engine does it use?
Prettier 3.9 (MIT), the most popular code formatter among web developers, running here in your browser.
Can I unminify a minified HTML page?
Yes, paste the minified page and you get clean code. Removed comments don’t come back, of course.
