HTML Beautifier turns minified or messy HTML into clean, indented code with one tag per line. Paste your HTML, choose the indent, click the button and copy the result. It is free and runs in your browser.
<!DOCTYPE html><html><head><title>MyPage</title></head><body><h1>Welcome</h1><p>This is my <b>first</b> page.</p><ul><li>One</li><li>Two</li><li>Three</li></ul><img src="logo.png" alt="Logo"></body></html>
<!DOCTYPE html>
<html>
<head>
<title>MyPage</title>
</head>
<body>
<h1>Welcome</h1>
<p>This is my <b>first</b> page.</p>
<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>
<img src="logo.png" alt="Logo">
</body>
</html>Bookmark: press Ctrl+D (Windows) or Cmd+D (Mac) to save this tool.
An HTML beautifier, also called an HTML formatter, adds line breaks and indentation to HTML. Minified code, which is written on one line to save space, becomes easy to read and edit.
The tool changes only whitespace: block tags such as div, p and li each get their own line, and nested tags are indented one level deeper. Inline tags such as b, a and span stay with their text, so the page looks the same. Tags, attributes, text and comments are kept.
It is made for plain HTML and does not check your code for errors. Use it before you edit a minified page, review a template or compare two versions.
Block tags go on their own lines, and inline tags stay with their text. These examples use a 2 space indent.
| Before | After |
|---|---|
<div><p>Hi</p></div> | <div> <p>Hi</p> </div> |
<ul><li>One</li><li>Two</li></ul> | <ul> <li>One</li> <li>Two</li> </ul> |
<p>Hello <b>world</b>!</p> | <p>Hello <b>world</b>!</p> |
<head><title>Page</title><meta charset="utf-8"></head> | <head> <title>Page</title> <meta charset="utf-8"> </head> |
Reading minified HTML, cleaning up a template before you edit it, making code reviews easier and comparing two versions of a page.
The tool does not validate HTML, and it does not reformat code inside script and style tags. Keep a copy of your original code, or use Undo right after formatting.
To format the styles in your page, use the CSS Beautifier. For other code, try the JavaScript, JSON or SQL beautifiers.
An HTML beautifier takes minified or messy HTML and adds line breaks and indentation, so every element is on its own line and nested tags are easy to follow. It is also called an HTML formatter.
Paste your HTML into the box, choose the indent size and click Beautify HTML. The formatted code replaces the text in the box. Click Copy to use it, or Undo to go back.
It should not. The tool changes only whitespace between tags, and it collapses runs of spaces and line breaks inside text, which browsers already treat as a single space. Tag names, attributes, text and comments are kept. Content inside pre, textarea, script and style is not reformatted.
Inline tags such as b, i, a and span, and the text around them, stay on the same line as their parent. Moving them onto separate lines could add visible spaces to your page. Block tags such as div, p and li each get their own line.
Beautifying adds line breaks and indentation to make HTML readable. Minifying removes them to make the file smaller. Use a beautifier when you want to read or edit code, and a minifier before you publish it.
You can choose 2 spaces, 4 spaces or a tab. Two spaces is a common choice for HTML, but use whatever your project or style guide requires.
Code inside script and style tags is moved onto its own lines and indented as a block, but it is not reformatted line by line. If it is minified, it stays on one line. Use the CSS Beautifier for style code.
No. It is a formatter, not a validator. It closes tags such as li, td and p in the common cases where the end tag is optional, but it does not report mistakes. Use an HTML validator or your editor to find them.
Yes. It is free, needs no account and runs in your browser, so your HTML is not uploaded to a server.
Last updated: 26 October 2026