Skip to content
XUtilHub

HTML Formatter & Beautifier – Pretty Print HTML Online

Format and beautify messy or minified HTML with proper indentation, including embedded CSS and JavaScript. Powered by Prettier.

  • Free, no sign-up
  • Runs in your browser, nothing uploaded
Input
Output

About the HTML Formatter

Turn minified or messy HTML into clean, readable, consistently indented markup. Embedded <style> and <script> blocks are formatted too.

Key features

  • Beautifies minified or messy HTML
  • Formats embedded CSS and JavaScript too
  • 2 spaces, 4 spaces or tabs
  • Line width of 80, 100 or 120
  • Syntax highlighting and error messages
  • Private: runs in your browser

Make HTML readable again

Minified HTML from a website, a one-line email template or markup exported from a page builder is hard to read and edit. Paste it in to get clean, consistently indented HTML, with embedded <style> and <script> blocks formatted too.

Before and after

<div class="card"><h1>Hello</h1><p>Some <strong>text</strong>.</p><ul><li>One</li><li>Two</li></ul></div>

becomes

<div class="card">
  <h1>Hello</h1>
  <p>Some <strong>text</strong>.</p>
  <ul>
    <li>One</li>
    <li>Two</li>
  </ul>
</div>

When to use it

  • Inspecting a page's source that was minified for production.
  • Cleaning up email templates and CMS exports before editing.
  • Code reviews: consistent formatting makes real changes easier to spot.
  • Learning: indentation shows how elements are nested.

CSS formatter, JavaScript formatter, HTML to Markdown, and HTML to text.

How to use the HTML Formatter

  1. Paste your code into the input box, upload a file, or click Sample to try it out.
  2. Choose the options you want, such as indentation, line width or dialect.
  3. The result appears instantly in the output panel. Syntax errors are shown with their line and column.
  4. Click Copy to copy the result, or Download to save it as a file.

Frequently asked questions

Which formatter does this use?

Prettier, the most widely used code formatter in web development. Your HTML is formatted the same way it would be in a project that uses Prettier.

Will formatting change how my page looks?

No. The formatter respects CSS display rules for whitespace, so inline elements like links and bold text aren't split in ways that add visible spaces.

Can it format HTML with errors?

Prettier needs reasonably valid HTML. If there's a problem, such as an unclosed tag in the wrong place, the error message shows where it is.

Does it work with templates like JSX, Vue or Angular?

This tool is for plain HTML. For JSX, use the JavaScript Formatter. Vue and Angular templates may work if they're also valid HTML.

Is my code uploaded anywhere?

No. Every developer tool runs entirely in your browser, so source code, configuration files and passwords never leave your device.

Which formatter do you use?

HTML, CSS and JavaScript are formatted with Prettier, the most widely used code formatter, so the output matches what most projects use. SQL uses sql-formatter, and minification uses Terser and CSSO.

Is there a size limit?

There's no fixed limit. Very large files (several megabytes) can take a few seconds, depending on your device.

Last updated:

Related Dev tools