Free tool

HTML formatter.

Paste a one-line blob from a build step, an export or a model that forgot line breaks, and get indented markup you can actually read. Flip to Minify to go the other way. Nothing inside <pre>, <script> or <style> is touched, and broken HTML is left broken rather than silently re-nested.

index.html
490 B in698 B out
33 lines

Publishes the document to Comma: one URL instead of an attachment nobody can open, private or open to anyone with the link, and readers comment on the exact paragraph instead of describing it back to you. Free, no card.

What the formatter does

  • Re-indents block tags to two spaces, four spaces or a tab, one level per nesting depth.
  • Collapses a short element and its contents onto one line — <li>, <td>, <h1> — so a table does not become three hundred lines.
  • Leaves <pre>, <code>, <script>, <style> and <textarea> byte for byte — their whitespace is semantic.
  • Keeps the space between inline elements. Up <strong>22%</strong> YoY does not become Up22%YoY.
  • Passes doctypes, comments and CDATA through untouched. Minifying can drop comments, never the doctype.
  • Does not repair markup. An unclosed tag comes out unclosed — a formatter that guesses at your structure is worse than one that leaves it alone.

When the file should be a link

Formatted or not, an .html file is still an attachment: the person you send it to downloads it, trusts it, opens it locally, and then replies in chat with “the second chart looks off” with no way to point at it. Published as a report it is one URL that renders the same for everyone, comments sit on the exact element they are about, and every re-publish is kept as a revision you can diff. An agent can do the whole loop over the MCP server — build the HTML, publish it, read the comments back.

Questions

How do I format HTML online?
Paste the HTML into the editor on this page, or drop an .html file onto it. It is re-indented as you type — pick two spaces, four spaces or tabs, then copy the result, download it as a file, or publish it as a shareable link. Nothing installs and nothing uploads.
What is the difference between formatting and minifying?
Formatting (beautifying) adds indentation and line breaks so a human can read the structure. Minifying removes the whitespace that does not affect rendering so the file transfers smaller. They are inverses: this page does both, and switching tabs runs the other direction on the same input.
Does formatting change how the page renders?
No. Indentation is added only where whitespace is already insignificant — between block-level tags. Content inside <pre>, <code>, <script>, <style> and <textarea> is passed through byte for byte, and a space between inline elements such as <strong> or <a> is preserved, because removing it would visibly join two words.
Will it fix broken HTML?
No, and that is deliberate. It is a whitespace pass over the tags it can see, not a parser that rewrites your document. An unclosed tag stays unclosed rather than being silently re-nested somewhere you did not intend — which is the behaviour you want before you publish something.
Does the minifier compress the CSS and JavaScript too?
No. Inline <style> and <script> blocks are left exactly as written. This is a markup whitespace minifier, so the output is always something you can still read and diff; run a dedicated CSS/JS minifier in your build if you need those compressed as well.
Are comments removed?
Only if you turn off “Keep comments”, and only when minifying. The doctype is always kept — dropping it would put the browser into quirks mode.
Is my HTML uploaded anywhere?
No. Formatting runs in your browser and the preview renders in a sandboxed iframe on this page. The markup only leaves your machine if you click “Get a shareable link” and create a report.

Related: HTML viewer · HTML diff · HTML to Markdown · all free tools · report types