HTML Formatter & Beautifier

Developer Tools

Paste HTML and get it indented and readable, or minified to one line, with inline scripts and styles formatted too.

Options
Input
Output

Processed in your browser. A copy of each run is saved to your past runs so you can reopen it. Privacy

About

What the HTML Formatter does

The HTML Formatter, also called an HTML beautifier, takes markup that arrived as one long line or with messy indentation and lays it out one element per line, nested by depth. It also formats the CSS and JavaScript inside <style> and <script> tags, and can minify the whole document instead. It is for developers, email builders and anyone reading markup copied from a browser or a CMS. It formats; it does not validate HTML against the spec.

Steps

How to use it

  1. 1Paste HTML into the Input panel, or upload an .html file.
  2. 2Pick an indent of 2 spaces, 4 spaces or a tab, and whether long lines should wrap.
  3. 3Press Format (or Cmd/Ctrl+Enter). Press Minify instead to get the same markup on one line.
  4. 4Copy the result or download it as formatted.html from the Output header.

Example

A real run

Input

<nav class="site-nav"><ul><li><a href="/">Home</a></li><li><a href="/pricing">Pricing</a></li><li class="active"><a href="/about">About</a></li></ul></nav>

Output

<nav class="site-nav">
  <ul>
    <li><a href="/">Home</a></li>
    <li><a href="/pricing">Pricing</a></li>
    <li class="active"><a href="/about">About</a></li>
  </ul>
</nav>

Format with a 2-space indent: the list sits one level under the nav and each item one level deeper. The short <li><a> pairs stay on one line because splitting them would add nothing but height.

Options

Every setting, and when to use it

Indent: 2 spaces, 4 spaces or tab
Two spaces is the common choice for front-end projects and templates; four suits teams that use it in their other languages; tabs let each reader pick a width. Nested elements are indented one step per level.
Wrap lines: off, 80 or 120 characters
Off keeps every element on as few lines as its structure needs. 80 or 120 breaks long runs of text and long attribute lists so the file reads well in a code review or a narrow editor pane.
Keep comments
On, HTML comments stay in place. Off removes them from the output, except conditional comments (<!--[if …]>) that some email clients still read. Use off before shipping markup or pasting it into a CMS.
Format inline script and style
On, the JavaScript inside <script> and the CSS inside <style> are indented as well. Off leaves their contents exactly as written, which is safer for templating code or minified third-party snippets.
Format or Minify
Format adds line breaks and indentation. Minify removes comments (unless kept) and collapses whitespace to one line, keeping a single space where it changes what renders, and leaves <pre>, <textarea>, <script> and <style> contents untouched.

Good to know

Common problems and limits

Input is limited to 5 MB. The formatter rearranges whitespace only; it does not add missing tags, fix attribute quoting or check the document against the HTML standard. For that, use the W3C Markup Validation Service.

Broken markup is formatted as far as possible. When tags look unbalanced, a warning lists the line of each unclosed or stray tag, for example "<span> is not closed before </div>". The check skips elements whose closing tag is optional, such as <p>, <li> and <td>.

Whitespace between inline elements can matter: the space in <b>big</b> <i>world</i> renders. Formatting keeps such spaces on the same line, and <pre> and <textarea> contents are never re-indented.

Template syntax (Handlebars, Liquid, Blade, JSX) is treated as text. Plain template tags usually survive, but mixed template logic inside attributes can be laid out oddly; check the result before committing it.

Audience

Who uses it

  • Front-end developersRead the markup a framework or a browser's Copy outerHTML produced, then check the change against the original with Text Compare.
  • Email and newsletter buildersUntangle table-based email HTML exported from a builder before editing one cell, and minify it again before sending.
  • Ecommerce teamsClean up a product description pasted into Shopify or WooCommerce as one line of HTML, so a non-developer can find the paragraph to change.
  • SEO and content teamsInspect the head of a page (canonical, meta tags, JSON-LD blocks) in a readable layout; JSON-LD itself formats best in the JSON Formatter.
  • StudentsSee the nesting of a page clearly while learning which element contains which.

FAQ

Frequently asked

What does an HTML beautifier do?

It rewrites HTML so the structure is visible: one element per line, children indented under their parent, and the CSS and JavaScript inside style and script tags laid out too. Only whitespace changes, so the page renders the same; it just becomes readable. This page does that and can also minify the markup back to one line.

How do I format HTML in VS Code?

VS Code formats HTML out of the box. Open the file and run Format Document: Shift+Alt+F on Windows and Linux, Shift+Option+F on Mac, or right-click and choose Format Document. Turning on Format On Save in the settings does it every time you save. For markup that is not in a file, paste it here and copy it back.

How do I format HTML in Notepad++?

Notepad++ has no built-in HTML formatter. Plugins such as XML Tools offer Pretty Print, which works on well-formed, XHTML-style markup but often fails on ordinary HTML with unclosed tags. Pasting the markup here, formatting it and copying it back is usually faster and handles unclosed tags.

Does formatting HTML change how the page looks?

Normally no, because browsers collapse whitespace between block elements. Two places need care: whitespace between inline elements, which renders as a space, and the contents of pre and textarea, where every space shows. This formatter keeps inline spacing on one line and never re-indents pre or textarea content.

What is the difference between formatting and minifying HTML?

Formatting adds line breaks and indentation so people can read and edit the markup. Minifying removes comments and extra whitespace so the file is smaller to send. Both describe the same document. Keep the formatted version in your source and ship the minified one if file size matters.

Does this tool validate my HTML?

No. It formats markup and warns when tags look unbalanced, but it does not check the document against the HTML standard, required attributes or accessibility rules. For a full check, run the page through the W3C Markup Validation Service at validator.w3.org.

Can it format HTML that contains JavaScript and CSS?

Yes. With Format inline script and style on, code inside script tags is indented as JavaScript and code inside style tags as CSS, in the same pass as the markup. Turn the option off to leave those blocks exactly as they are, for example when they hold template code.

Automation: an MCP tool format_html(html, indent, minify) → html and an n8n node are planned for this tool.

Built and maintained by Radhika SinghLast updated Questions: hello@operativez.ai