HTML Formatter

Indent messy HTML so it is easy to read, or minify it to a single line.

How to Use HTML Formatter

  1. Paste your HTML.
  2. Choose an indent size: 2, 4 or 8 spaces.
  3. Click Format HTML to beautify, or Minify HTML to compress.
  4. Copy the result.

How formatting works

Each tag and each run of text goes on its own line, indented one step deeper inside every element that isn't closed yet. Void elements such as br, img, input and meta don't add indentation, comments and doctype stay where they are, and a stray closing tag can't throw the indentation off.

The contents of pre, textarea, script and style blocks are kept exactly as written, because whitespace inside them matters; squashing a script onto one line can turn the rest of it into a comment.

Safe minifying

Minify removes HTML comments and turns runs of spaces, tabs and line breaks into single spaces. Whitespace between tags is reduced to one space rather than deleted, because between inline elements like links and bold text it's visible on the page. That makes the output a little larger than aggressive minifiers produce, but it never changes how the page looks.

Key Features & Practical Use Cases

  • Making minified or copied HTML readable so you can find and edit something.
  • Tidying up HTML exported by an email builder or CMS.
  • Shrinking an HTML snippet before embedding it somewhere.

Frequently Asked Questions

Will formatting change how my page looks?

Formatting adds line breaks and indentation, which browsers treat as spaces. In rare layouts that depend on no space between inline elements, check the result.

Does it format CSS and JavaScript inside the HTML?

No. Script and style blocks are kept exactly as they are.

Does it check my HTML for errors?

No, it's a formatter, not a validator. Use the W3C validator to check markup.

Is my code uploaded?

No. Formatting happens in your browser.

About OneClickly

OneClickly is a set of 119 free tools for PDFs, images, text, everyday math and code. They run in your browser, so the files and text you work with stay on your device.

Related Tools