๐Ÿ”’ Runs in your browser โ€” nothing is uploadedโœ“ Free, no signup

HTML Formatter & Beautifier

Paste messy or minified HTML to get clean, consistently indented markup โ€” or minify it to make it smaller.

Loading...

0 characters

Loading...

When should you use the HTML Formatter?

  • Reading minified HTML copied from a page's source
  • Cleaning up HTML exported from an email builder or CMS
  • Shrinking an HTML template before shipping it

How to use the HTML Formatter

  1. 1

    Paste your HTML

    Paste a snippet or a full document into the input editor, or click Load sample.

  2. 2

    Choose indentation

    Pick 2 spaces, 4 spaces or tabs, and optionally wrap long lines.

  3. 3

    Format or minify

    Click Format HTML for readable markup or Minify for a smaller file.

  4. 4

    Copy the result

    Use Copy Output to copy the result.

Examples

One-line HTML to readable markup

Before

<div><p>Hi <b>there</b></p><ul><li>a</li><li>b</li></ul></div>

After

<div>
  <p>Hi <b>there</b></p>
  <ul>
    <li>a</li>
    <li>b</li>
  </ul>
</div>

Common errors and how to fix them

The indentation drifts further and further right
There's probably an unclosed tag such as a <div> without </div>. Find where the indentation stops returning to the left.
Text inside <pre> wasn't re-indented
That's intentional โ€” whitespace inside <pre> and <textarea> is shown on the page, so changing it would change what visitors see.
Related tools:ย CSS Minifier ยท JS Minifier ยท Markdown Editor

More from Code Formatters & Minifiers

Free tools that run in your browser โ€” no signup, nothing uploaded.

HTML Formatter FAQ

It re-indents HTML so each nested element sits on its own line at the right depth, making messy or minified markup easy to read and edit. The page renders exactly the same.

No. Only whitespace between tags changes. Content inside <pre>, <textarea>, <script> and <style> is kept as it is.

It removes comments and collapses runs of spaces and line breaks into a single space to make the file smaller. It keeps one space between tags so inline elements like <b> and <i> don't run together.

Yes. Embedded <style> and <script> blocks are indented along with the HTML. For large stylesheets or scripts, use the CSS Minifier or JS Minifier, which can also beautify.

No. It formats what you give it but doesn't close missing tags or repair invalid markup. Unclosed tags can make the indentation look uneven, which is a useful clue to where the problem is.

No. Formatting and minifying run in your browser, and nothing is sent to a server.