HTML Formatter

Paste HTML to beautify or minify it in your browser. Pick 2 spaces, 4 spaces, or a tab for the indent. Nothing is uploaded.

  • Beautify
  • Minify
  • Indent: 2, 4, or tab

Beautify or minify HTML in this tab. Choose 2 spaces, 4 spaces, or tabs. Scripts, styles, and pre blocks are left as written. Nothing is uploaded.

Paste HTML to beautify it with indentation or minify it, then copy or download the result.

An HTML formatter turns a minified or messy page into readable, indented markup. Every nested element gets its own line and level, so you can scan the structure, spot a missing closing tag, and copy a clean version back into your editor.

Beautify adds the indentation. Minify does the opposite: it drops comments and the whitespace between tags to make the file smaller. Script, style, pre, and textarea content is left exactly as written, and the output shows its element count, attribute count, nesting depth, and size in bytes.

Everything stays in this tab, with no upload and no account. Working with data instead? Use the JSON formatter or the XML formatter. Tidy a query with the SQL formatter, or check structured data with the schema markup validator. More utilities live on the Developer hub.

How to use the XML formatter

  1. Paste HTML into the box, or load the sample.
  2. Choose Beautify or Minify.
  3. Pick 2 spaces, 4 spaces, or a tab for the indent.
  4. Copy the result or download it as a .html file.
  5. Clear the box when you are done. Nothing is stored.

Frequently asked questions

What does an HTML formatter do?

An HTML formatter re-indents markup so every nested element sits on its own line at the right depth. It turns a minified or messy page into code you can read, without changing the tags, attributes, or text.

How do I format HTML online?

Paste your HTML into the box, choose Beautify, pick 2 spaces, 4 spaces, or a tab, and press Format. The result appears below with a copy button and a download button.

How do I minify HTML?

Switch the output to Minify. The tool removes comments and the whitespace between tags and collapses runs of spaces in text, which shrinks the file. Scripts, styles, and pre blocks are kept as written.

What is the difference between beautify and minify?

Beautify adds line breaks and indentation so people can read the code. Minify strips that extra whitespace so the file is smaller to send. Both produce the same page in a browser.

Does formatting change how my page looks?

It should not. Tags, attributes, and text stay as you wrote them. Whitespace inside script, style, pre, and textarea blocks is left alone, and text outside them is collapsed to single spaces, which browsers already do when they render.

Will it fix broken HTML?

No. It is a formatter, not a validator. Unclosed or stray tags are tolerated and left as they are, so use a validator to find markup errors.

Which indent should I use?

Use whatever your project uses. Two spaces is common for web code, four spaces is common in many style guides, and tabs let each person set their own display width.

Is my HTML sent anywhere?

No. Formatting runs in your browser. Nothing you paste is uploaded or stored, so it is safe for internal templates and drafts.