RevealTheme logo

HTML Formatter & Beautifier

Format minified or inline HTML with proper indentation and line breaks.

How to use this tool

  1. 1

    Paste your minified or single-line HTML into the input box.

  2. 2

    Read the indented result that appears below as you type — there is no button to press.

  3. 3

    Select and copy the formatted output from the result panel.

  4. 4

    Spot-check anything with <pre>, <textarea>, comments, or inline scripts, since those are not handled perfectly.

What does this HTML formatter actually do?

It re-indents HTML so nested elements become readable: each tag goes on its own line, and every level of nesting adds two spaces of indentation. Void elements that never have children — img, br, hr, input, meta, link and the rest — stay inline and do not increase the indent. Internally it is a regex tokenizer, not a real HTML parser. It splits the markup on anything between < and >, collapses whitespace that sits between tags, and trims text nodes. That makes it fast and dependency-free, but it has real limits you should know. Because it removes whitespace between and inside elements, the output is not guaranteed to render identically to the input: significant whitespace between inline elements (a space between two <span> tags, for example) is lost, and the contents of <pre> and <textarea>, where whitespace is meaningful, get collapsed. The tokenizer also does not specially handle comments, <script>/<style> bodies, or attributes whose values contain a > character. For everyday minified markup it works well; for those edge cases, reach for a full parser-based formatter such as Prettier or js-beautify.

Common use cases

  • Expanding a minified production HTML page so you can read its structure during debugging.

  • Tidying a snippet copied from a browser's DevTools Elements panel before pasting it into documentation.

  • Re-indenting a fragment of email or marketing HTML that arrived as one long line.

  • Inspecting the nesting and tag hierarchy of unfamiliar markup at a glance.

  • Cleaning up generated or template-output HTML before committing it to a repository.

  • Teaching or reviewing HTML structure where consistent two-space indentation makes nesting obvious.

Frequently asked questions

Does the formatted output render exactly like my original HTML?
Not always. The tool collapses whitespace between tags and trims text, so a meaningful space between inline elements (like a space between two <span> tags) can disappear. For most block-level markup the rendered result is identical, but treat whitespace-sensitive content with care.
Will it preserve whitespace inside <pre> or <textarea>?
No. Whitespace is significant inside those elements, but the formatter trims and re-indents text nodes everywhere, so <pre> and <textarea> content gets collapsed. Restore that whitespace manually, or use a parser-based formatter for such files.
How does it handle HTML comments and <script> or <style> blocks?
It does not special-case them. A comment is treated like a tag and can throw off indentation, and the bodies of <script> and <style> are tokenized as ordinary text, so code containing < or > may be mis-split. Keep these in mind for pages heavy with inline scripts.
Is this a real HTML parser?
No. It is a lightweight regex tokenizer that splits on < and > and tracks nesting depth. It has no DOM model, so unclosed or malformed tags and attributes containing a > inside quotes (such as title="a > b") will mis-indent. For guaranteed-correct formatting of complex documents, use Prettier or js-beautify.
How much does it indent, and can I change it?
It uses a fixed two spaces per nesting level. There is no option to switch to tabs or a different width; if you need configurable indentation, a tool like Prettier exposes those settings.
Is my HTML uploaded anywhere?
No. Formatting runs entirely in your browser using local JavaScript. Nothing you paste is sent to a server, so you can safely format private or proprietary markup.

Related tools