Skip to content
toolstome

HTML formatter and minifier

Paste HTML and get it back tidy: each block element on its own line with consistent indentation, inline elements and text kept together, and comments and the doctype preserved. Switch to Minify to remove comments and whitespace between tags for a smaller file. Whitespace inside pre and textarea is never changed, and the contents of script and style blocks are kept as written, only re-indented. Attribute values, including any that contain angle brackets, are left exactly as they are.

Free · No sign-upProcessed in your browser

Mode

Indent

Contents of pre, textarea, script and style are kept as written.

How to use the HTML Formatter

  1. 1

    Paste your HTML

    A fragment or a whole page.

  2. 2

    Choose beautify or minify

    Pick 2 spaces, 4 spaces or tabs for indentation.

  3. 3

    Copy or download

    Use the copy button or download the file.

When to use it

  • Read HTML copied from a browser’s developer tools or an email.
  • Clean up template output before reviewing it.
  • Shrink HTML for a production build.

Limits

  • The formatter does not validate or repair broken HTML.
  • Whitespace between inline elements is significant in HTML; the minifier keeps one space there to avoid joining words.

Privacy

HTML is formatted in your browser. Nothing you paste is sent anywhere.

Frequently asked questions

Will formatting change how my page looks?

Rarely. Whitespace inside pre and textarea is untouched, but extra spaces between inline elements can matter in some layouts; check the result.

Does it format JavaScript and CSS inside the page?

Script and style blocks are re-indented as a whole but their code is not reformatted.

Is minified HTML much smaller?

Usually 10 to 30%, more with many comments. Server compression such as gzip saves far more, so use both.

Does it remove conditional comments?

No. Comments starting with [if are kept when minifying.

Is my code uploaded?

No. It is processed in your browser.

People also use

Last updated November 22, 2026 · How we build and test our tools

Categories

Recently used tools

Tools you open will appear here.

More