Free online text tool

HTML Beautifier

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.

HTML Beautifier Tool

0Character Count
0Character Count (without spaces)
0Word Count
0Sentence Count
0Paragraph Count
0Line Count

HTML Beautifier Example

Before
<!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>
After
<!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.

Suggest a New ToolProvide Feedback on This Tool

What is an HTML beautifier?

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.

HTML beautifier examples

Block tags go on their own lines, and inline tags stay with their text. These examples use a 2 space indent.

BeforeAfter
<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>

How to beautify HTML

  1. 1
    Paste your HTML
    Paste minified or messy HTML into the box, or import a text file.
  2. 2
    Choose the indent
    Pick 2 spaces, 4 spaces or a tab.
  3. 3
    Click Beautify HTML
    The code in the box is formatted at once. Use Undo if you change your mind.
  4. 4
    Copy it
    Click Copy and paste the formatted HTML into your editor.

When to use an HTML beautifier

Good for

Reading minified HTML, cleaning up a template before you edit it, making code reviews easier and comparing two versions of a page.

Check first

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.

Other tools

To format the styles in your page, use the CSS Beautifier. For other code, try the JavaScript, JSON or SQL beautifiers.

HTML beautifier FAQ

What is an HTML beautifier?

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.

How do I beautify HTML?

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.

Does it change how my page looks?

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.

Why are some tags kept on one line?

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.

What is the difference between beautifying and minifying HTML?

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.

Which indent size can I choose?

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.

Does it format the CSS and JavaScript inside my page?

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.

Does it check my HTML for errors?

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.

Is this tool free and is my code private?

Yes. It is free, needs no account and runs in your browser, so your HTML is not uploaded to a server.

Looking for more text tools?

Browse Formatter Tools

Last updated: 26 October 2026