⚡
usefultools.dev
</>

HTML Formatter & Minifier – Beautify HTML Online

NEW

HTML formatter that beautifies messy markup with clean indentation or minifies it for production, and flags unclosed tags. Free and private, runs in your browser.

Runs 100% in your browser — your input is never uploaded or stored on our servers.

1 markup warning (output was still produced):

  • Line 9, column 6: <span> is not closed before </div>
512 → 645 bytes
⚡

Quick Examples

Typical inputs and the results this tool produces.

Beautify
<div><p>Hi</p></div>
<div> <p>Hi</p> </div>
Minify
<p> Hi <b>there</b> </p>
<p>Hi <b>there</b></p>
Comments
<div><!-- note -->ok</div>
<div>ok</div>
Warning
<p>Hi<div>x</div></span>
Line 1, column 18: stray closing tag </span>…
📖

Overview

This HTML formatter turns minified or hand-mangled markup into readable, consistently indented code, and does the reverse with a minify mode that strips comments and needless whitespace. Choose 2 spaces, 4 spaces or tabs, decide when long tags get one attribute per line, and pick <br> or <br /> for void elements.

Front-end developers use it to read HTML copied from DevTools, email templates or CMS exports, and to shrink snippets before embedding them. Inline elements such as <a>, <b> and <span> stay on the same line as their text, while the contents of <pre>, <textarea>, <script> and <style> are kept exactly as written.

The markup is parsed by a small tokenizer in your browser; nothing is uploaded. Unclosed or stray tags do not stop the beautify HTML process: they are listed as warnings with line and column so you can fix the source.

Why use this tool?

  • Readable HTML in one paste, no install
  • Minify mode for smaller pages and templates
  • Never touches pre, textarea, script or style content
  • Points out unclosed and stray tags by line
  • Private: markup never leaves your browser
⭐

Features

🧹

Beautify or minify

Switch between indented output and a compact single-line version of the same markup.

↹

Indent options

Indent with 2 spaces, 4 spaces or tabs, and choose <br> or <br /> for void elements.

📏

Attribute wrapping

Put each attribute on its own line for long tags, for every tag with several attributes, or never.

🛡️

Safe whitespace handling

Inline text keeps its spacing, and pre, textarea, script and style blocks are copied verbatim.

⚠️

Unclosed tag warnings

Missing end tags and stray closing tags are reported with line and column; optional ones like </li> are not.

📋

Copy or download

Copy the result or save it as an .html file, with the byte size before and after.

🛠️

How to Use

1

Paste your HTML

Paste markup into the HTML input box, or press Sample to try it.

2

Pick a mode

Choose Beautify for readable code or Minify for compact output.

3

Set the options

Pick indent, attribute wrapping and void style, or the minify checkboxes.

4

Copy the result

Check any warnings, then press Copy or Download.

🤔

Frequently Asked Questions