⚡Free Tools

HTML Formatter, Beautifier & Viewer

Beautify messy or minified HTML in one click, preview it live at phone, tablet or desktop width, and see unclosed tags, duplicate IDs and missing alt text by line. Nothing is uploaded.

Input HTML

What this HTML formatter does

Paste any HTML — a minified page source, an email template, a CMS export, a snippet copied from DevTools or a Vue, Handlebars, Jinja or EJS template — and press Format HTML or Ctrl+Enter. The markup is re-indented with 2 spaces, 4 spaces or tabs, long lines are wrapped at 80 or 120 characters if you want, and the CSS inside <style> and the JavaScript inside <script> are formatted too. Three tabs sit on the output side: the formatted code, a live preview of the page at phone, tablet or full width, and an Issues list that points at unclosed tags, duplicate IDs and missing alt text by line number.

Everything runs in this browser tab with the open-source js-beautify engine, bundled with the page rather than loaded from a CDN. Your markup is never uploaded, so it is safe to paste client templates, admin panels or pages behind a login. Once the page has loaded you can go offline, or install it as an app from the button at the top.

How the formatting works

HTML is not XML, so a good HTML beautifier has to understand the rules in the WHATWG HTML Living Standard rather than simply indenting every tag. This tool follows those rules:

Formatting only changes whitespace between tags. It does not reorder attributes, add missing tags or rewrite your markup the way a browser's parser would, so what you get back is still recognisably your code.

The Issues tab: a quick HTML checker

Every time you format or minify, the tool also scans the markup and lists problems with the line number. Click a line number to jump to it in the editor. It reports:

This is a fast first pass, not a full conformance checker. Before you ship an important page, also run it through the W3C Nu Html Checker, which implements the complete specification.

Live HTML viewer, safely sandboxed

The Live preview tab renders your HTML in an <iframe> with the sandbox attribute. By default scripts, forms, pop-ups and plugins are all blocked, so you can open markup from an unknown source without it running anything. If you need to see a script-driven widget, tick Run scripts: scripts are then allowed but the frame is still given a unique, opaque origin, so it cannot read this page, your cookies or your saved history. Use the 375 px, 768 px and full-width buttons to check a responsive layout at phone and tablet sizes without leaving the page.

Minify HTML without breaking it

Minify removes indentation and line breaks and collapses runs of spaces. It is deliberately conservative: whitespace is only removed next to block-level tags such as <div>, <p> and <li>, while a single space is kept between inline elements, because <b>Hello</b> <i>world</i> and <b>Hello</b><i>world</i> render differently. The contents of <pre>, <textarea>, <script> and <style> are left untouched; JSON-LD structured data is compacted safely. Comments are kept unless you tick Remove comments, and Internet Explorer conditional comments and <!--! … --> licence comments are always kept. The stats bar shows the size before and after.

Minifying HTML usually saves 5–20% before compression. Your server's gzip or Brotli compression saves far more, so turn that on first, and treat minification as an extra.

More actions

Typical uses

Developers use an HTML formatter to read the minified output of a framework or a page builder, to review a pull request, or to tidy a template before committing it. Bloggers and WordPress users use it to clean up markup pasted from Word or Google Docs. Email marketers use it on table-heavy newsletter templates, where one missing </td> breaks the layout in Outlook. Students use the preview as a quick online HTML viewer for practice exercises. SEO specialists use the Issues tab to spot missing titles, alt text and language attributes.

Tips for clean HTML

Privacy, offline use and limits

All work happens locally. Drafts and the last 12 inputs are stored only in this browser's localStorage, and you can clear them from the History dialog. The tool has been tested with documents larger than 1 MB, with Hindi and emoji text, and with broken markup. Formatting is best-effort on badly broken HTML: if tags are mismatched, fix the issues listed first, then format again.

Sources and standards

Frequently asked questions

Is my HTML uploaded to a server?

No. Formatting, checking and previewing all run in this browser tab with a locally bundled copy of js-beautify. You can disconnect from the internet after the page loads.

Is the live preview safe for unknown HTML?

Yes. The preview is a sandboxed iframe. Scripts, forms and pop-ups are blocked unless you tick Run scripts, and even then the frame has an opaque origin, so it cannot read this page, cookies or storage.

Does formatting change how my page looks?

No. Inline elements stay on their line and pre/textarea content is untouched, so the rendered page stays the same. Only indentation between block elements changes.

Why isn't a missing &lt;/p&gt; or &lt;/li&gt; reported?

The HTML standard makes the end tags of p, li, td, tr, option and a few other elements optional, so leaving them out is valid HTML. Unclosed div, span, a, section and similar elements are reported.

Is this a full HTML validator?

It is a fast first-pass checker for the most common mistakes. For full conformance against the HTML Living Standard, also use the W3C Nu Html Checker.

Can it format Vue, Handlebars, Jinja or PHP templates?

Yes for the HTML parts. Template tags like {{ }}, {% %} and <% %> are detected and kept intact. PHP logic itself is not re-indented.

Keyboard shortcuts

Ctrl + EnterFormat HTML
Ctrl + Shift + MMinify
Ctrl + Shift + PLive preview
Ctrl + Shift + CCopy output
Ctrl + SDownload