Command Palette

Search for a command to run...

HT

HTML Formatter

Format, beautify, and minify HTML online. Re-indents messy or minified markup, keeps script, style, and pre content verbatim, and runs entirely in your browser.

What is an HTML Formatter?

An HTML formatter rewrites HTML markup with clean, consistent indentation so the structure of the document is easy to read. Paste a minified page, a snippet copied out of a build tool, or hand-written markup with mismatched tabs and spaces, and the formatter parses the tag tree and prints it back with one level of indentation per nesting depth. The reverse operation, minifying, strips the insignificant whitespace between tags to shrink the file for production without changing how the browser renders it.

Raw HTML rarely arrives in a state you can scan. Server templates emit it on a single line, bundlers collapse it, and pasted fragments carry whatever spacing the source used. Beautifying exposes the nesting so you can find the element you need, spot a tag that was never closed, or diff two versions cleanly. This matters most when you are debugging a layout, auditing markup for accessibility, or reading someone else's content for the first time. A formatter turns a wall of angle brackets into an outline you can follow.

A worked example shows what this free HTML formatter does with sloppy input. Paste <ul><li>One<li>Two</ul><p>Hi <b>there</b>, keep Beautify and 2 spaces selected, and click Format. The online HTML formatter closes both list items and the paragraph, puts each li on its own indented line, and keeps <p>Hi <b>there</b></p> on one line because it is short inline content. The output reads 5 tags, 5 lines, 63 bytes, and two warnings list what was auto-closed, so the HTML code formatter never repairs broken markup silently.

This tool runs 100% in your browser with a dependency-free parser, so nothing you paste is uploaded or logged, and it keeps working offline once the page has loaded. The parser is deliberately tolerant: it applies the same implied-closing rules a browser uses for tags like li, p, td, and option, so real-world markup with omitted end tags still formats correctly. Content inside script, style, pre, textarea, and title is copied verbatim, which means your JavaScript, CSS, and pre-formatted text are never reindented or broken.

How to use the HTML Formatter?

  1. Paste your HTML

    Paste any HTML into the input panel, whether it is minified onto one line, indented inconsistently, or a fragment copied from a template. Click Load Sample to start from a small realistic page.

  2. Choose beautify or minify

    Pick Beautify to re-indent the markup for reading and editing, or Minify to collapse it to the smallest whitespace-free form for production.

  3. Set indentation and options

    Select 2 spaces, 4 spaces, or tabs for beautify output, and optionally remove HTML comments. The document is parsed first, so unclosed tags are reported as warnings.

  4. Copy or download the result

    Copy the formatted HTML to your clipboard or download it as an .html file, then drop it into your editor, template, or page.

Key Features

  • Beautify and Minify

    Re-indent HTML with 2-space, 4-space, or tab indentation for readability, or minify it to the smallest whitespace-free form, both from the same tool.

  • Tolerant Parser

    Applies the browser implied-closing rules for tags like li, p, td, and option, so markup with omitted end tags still formats correctly rather than breaking.

  • Script and Style Preserved

    Content inside script, style, pre, textarea, and title is copied verbatim, so your JavaScript, CSS, and pre-formatted text are never reindented or altered.

  • Inline-Aware Output

    Short paragraphs and inline runs like a, strong, and em stay on one line instead of being split tag by tag, so the result reads the way you would write it.

Frequently Asked Questions

Paste the HTML into the HTML Input panel, choose Beautify, pick 2 spaces, 4 spaces or Tab, and click Format. The tool parses the tag tree and re-indents it, even when the input is a single minified line, then lets you copy the result or download it as formatted.html. All processing happens in your browser, so the markup is not uploaded.

Comments

0 comments

0/2000 characters

No comments yet. Be the first to share your thoughts!

html formatterhtml beautifierbeautify htmlformat htmlhtml minifierhtml pretty printindent htmlhtml formatter onlineclean up htmlhtml formatter freeonline html formatterhtml code formatter