Reformat messy markup with consistent indentation using the browser’s HTML parser (DOMParser). Comments, elements, and text nodes are walked and
printed line-by-line; <script>, <style>, <pre>, and <textarea> bodies keep their inner text with only indent
prefixes added. Nothing is uploaded.
No file loaded
Readable markup is easier to review in diffs, teach with, and debug. Minified or one-line HTML saves bytes but hides structure. A beautifier adds line breaks and indentation so nested elements line up visually — without changing the browser’s interpretation of the document (aside from how forgiving parsers normalize malformed input).
The page uses DOMParser to build a live DOM, then walks it to print each element, comment, and text node. Void elements (for example <br>,
<img>, <meta>) are written as a single opening tag. Raw text regions inside <script>, <style>,
<pre>, and <textarea> are copied from textContent with extra indent on each line — the tool does not re-parse JavaScript or CSS inside those
tags.
<!DOCTYPE html> to match a complete document.The parser may repair broken HTML (close tags, reorder elements), so output can differ from your source even before indentation. For production, pair beautification with tests and your usual linter. Very large documents may stress tab memory — this page caps input length.
No. Parsing and printing happen in your browser. For confidential templates, follow your organization’s policies on web-based tools.
The browser’s HTML parser builds a canonical DOM. Tags may be reordered or implied (for example <html>, <head>, <body>) when you paste a
fragment. That is parser behavior, not the formatter alone.
<script>?
The tool writes back the script body from textContent. It does not minify or pretty-print JS syntax inside the tag. If the parser altered the document, review the script block
in the output before deploying.
No. Those tools often use richer rules (wrap width, attribute sorting, framework-specific formatting). This page focuses on structural indentation from the DOM.
Very large inputs may slow the tab or exceed the cap. Split work or use offline tooling for massive templates.
DOMParser with text/html produces a document tree. A pasted fragment is wrapped in <html> and <body> when needed. Copy only the
part you need if you intended a partial snippet.
Typically beautify for editing and minify for deployment. Do not round-trip minified production assets through beautifiers in CI unless your pipeline expects it.