Free HTML Formatter & Beautifier

Free HTML formatter: beautify minified or messy HTML with clean indentation, or minify it by stripping comments and whitespace. Pick 2, 4 spaces or tabs.

  • No upload, 100% private
  • Instant, in your browser
  • 100% free, no signup
Loading tool…
Read the complete guideHow to Beautify or Minify HTML Without Breaking the Layout →

About the HTML Formatter tool

Minified templates, HTML copied from a browser’s “view source”, email templates and CMS exports are often squeezed onto a few very long lines. This HTML formatter beautifies that markup with consistent indentation so you can see which tags are nested inside which, find unclosed elements and edit the page comfortably.

Beautifying is done with js-beautify, the same engine behind many code editors’ format commands. It indents the head and body content, puts block elements on their own lines and also formats embedded <style> and <script> blocks. You choose between 2 spaces, 4 spaces or tabs. Switch on “Minify” to go the other way: HTML comments are removed and runs of spaces and line breaks are collapsed to a single space, while the contents of <pre>, <textarea>, <script> and <style> are left exactly as they were so nothing that depends on whitespace breaks. Conditional comments for old Internet Explorer are kept.

Formatting runs locally in your browser, so private templates and pages behind a login are never uploaded. It is ideal for quick one-off clean-ups when your editor is not at hand.

How to use HTML Formatter

  1. Paste HTML into the “HTML input” box, open an .html file with “Open file”, or click “Load sample”.
  2. Choose an “Indent size”: 2 spaces, 4 spaces or tab.
  3. Leave “Minify” off to beautify, or switch it on to compress the markup.
  4. Check the result in the output panel as you type.
  5. Click “Copy” or “Download” to save the formatted or minified file.

Features

js-beautify engine

Reliable, editor-grade HTML formatting including inline CSS and JavaScript blocks.

Indent options

Format with 2 spaces, 4 spaces or tabs to match your project style.

Safe minify

Removes comments and collapses whitespace but never touches <pre>, <textarea>, <script> or <style>.

Live preview

The output updates automatically as you edit the input or options.

Copy or download

Save the result as an .html file or copy it to the clipboard.

When to use it

  • Make minified page source readable while debugging layout issues.
  • Clean up HTML email templates before editing them.
  • Tidy HTML exported from a CMS, website builder or WYSIWYG editor.
  • Shrink a static page or snippet by removing comments and extra spaces.
  • Format code samples for documentation and blog posts.

Frequently asked questions

Does the formatter fix broken HTML?

No. It re-indents what is there but does not add missing closing tags or correct invalid nesting. Poor indentation in the output is often a clue to where a tag is missing.

How much does Minify reduce file size?

It removes comments and repeated whitespace, which typically saves 10–30% on hand-written HTML. It does not shorten attributes or remove optional tags like a full minifier would.

Will minifying change how my page looks?

It keeps a single space wherever there was whitespace, so inline text spacing is preserved, and it leaves <pre> and <textarea> content unchanged.

Can it format Vue, JSX or template syntax?

Plain HTML-like templates usually format well, but JSX and template languages with custom syntax may not be handled perfectly.

Is my code uploaded?

No. Both formatting and minifying run in your browser.

Which indentation should I choose?

Use whatever your project already uses. Two spaces is common in web projects and keeps deeply nested HTML narrow, while four spaces or tabs can be easier to scan.

Related tools