HTML formatter

Paste messy or one-line HTML and get clean, indented code back. Or squash it down to the smallest size.

Paste HTML on the left. The tidy version appears on the right as you type.

See the page, on screen or on your phoneOpen it in the HTML viewer, or get a review link with a QR code for your phone. People click anything on the page to comment.

How to use the HTML formatter

  1. Paste or openPaste HTML on the left, or open or drop an .html file.
  2. Pick a styleChoose 2 spaces, 4 spaces or tabs. Or press Minify for the smallest version.
  3. Copy or downloadCopy the result or download it as a file.
  4. See itOpen it in the HTML viewer, or get a review link to see it on your phone and share it.

What it checks

One element per lineBlock elements such as div, section, p and li each get their own line, nested by depth.
Inline stays inlineLinks, bold text and spans stay inside their sentence, so text still reads naturally.
Code blocks untouchedAnything inside pre, script, style or textarea is kept exactly as written.
PrivateFormatting happens in your browser. Nothing is uploaded unless you choose to share.

What an HTML formatter does

An HTML formatter, sometimes called an HTML beautifier, rewrites code so people can read it. It puts each block element on its own line and indents it by how deeply it sits inside other elements. The page looks exactly the same in a browser. Only the code changes.

When you need one

  • HTML from AI tools. ChatGPT, Claude and other tools often hand over a page as one long block. Formatting it makes it easy to find the heading or button you want to change.
  • Exported or minified code. Email builders, page builders and build tools squash HTML onto one line to save space.
  • Code reviews. Consistent indentation makes it obvious when a tag is missing or closed in the wrong place.

Formatting versus minifying

Formatting adds line breaks and indentation for people. Minifying removes them for machines, so the file downloads a little faster. Keep the formatted version to edit, and minify only the copy that goes live. HTML is already small, so minifying usually saves less than images or scripts would.

After formatting

Check the page itself before you share it. The HTML viewer shows it at desktop, tablet and phone width, and a review link lets your team or client click any part of the page to comment on it.

Questions

Is this HTML formatter free?

Yes. It runs in your browser with no signup and no limits.

Does formatting change how my page looks?

No. It only adds line breaks and indentation between tags. Text inside pre and textarea, and code inside script and style, is left exactly as it was.

Can I choose tabs or spaces?

Yes. Pick 2 spaces, 4 spaces or tabs above the code.

What does Minify do?

It removes comments, line breaks and extra spaces between tags, so the file is as small as possible. Press Format to switch back.

Is my code uploaded?

No. Formatting happens in your browser. The code only leaves your computer if you press Get a review link.

Can it fix broken HTML?

It tidies the layout of the code but doesn't repair missing or mismatched tags. Opening the result in the HTML viewer shows you quickly whether the page renders as expected.

More free tools