TheDevTab
Tools

Search tools and guides

Ctrl K

Keyboard shortcuts

Ctrl K
Search tools and guides
?
Show keyboard shortcuts
Escape
Close menus and dialogs

HTML Formatter

Adjust indentation or minify markup without executing embedded content.

Runs in your browser. Nothing is uploaded.

Format HTML privately

TheDevTab formats HTML in your browser. Nothing is uploaded while you paste, format, copy, or download a document.

The formatter works on text only. It does not execute scripts, load referenced resources, or connect to a server while formatting.

Formatter versus validator

A formatter changes layout so humans can review markup. This tool is not an HTML validator or linter, so malformed markup can still produce best-effort output and a tidy result can still have structural or accessibility problems.

Review the result in the context of the browser, framework, and HTML rules that your project uses. For text patterns around generated markup, try the Regex Tester.

What the formatter does

HTML Formatter puts tags on separate lines, indents nested elements by two spaces, keeps comments and doctypes, and recognizes void tags such as <br> and <img>. Text nodes are trimmed onto their own indented lines.

Script, style, pre, and textarea contents stay intact instead of being re-indented. Attribute order and text are preserved as much as practical, while malformed input is handled without a crash.

Use formatted HTML as a review aid

Start with the Sample action, paste markup, or drop a local .html file. Compare the formatted output with your original markup. Copy or download formatted.html after checking nesting, attributes, and embedded content. For another local formatting workflow, see the SQL Formatter.

FAQ

What happens when I drop an HTML file?

A dropped file is read as text and formatted in your browser. The HTML is never uploaded, and the output is produced locally.

Is HTML Formatter a validator or linter?

No. It is a best-effort formatter for indentation and layout, not a proof that markup is valid, accessible, or safe. Use an HTML validator, accessibility checker, or framework tool for those checks.

How does HTML Formatter handle void tags?

Elements such as area, br, col, embed, hr, img, input, link, meta, source, track, and wbr do not receive child indentation. A normal void tag and a self-closing form such as br/ are both treated as non-container elements.

Are script and pre contents changed?

No. script, style, pre, and textarea content is kept as one raw token instead of being re-indented by the formatter. The surrounding elements can still be placed on separate lines.

What does Minify change?

Minify trims tag and comment tokens and collapses runs of whitespace in ordinary text. Raw content inside script, style, pre, and textarea remains unchanged.

Which indentation options are available?

Pretty mode supports 2 spaces, 4 spaces, or a tab for each nesting level. The indent setting has no effect in Minify mode.