Trexmi
Developer Ready

HTML Beautifier

Indent minified or messy HTML so the nesting is easy to read. Every tag and text run goes on its own line, indented by depth.

Indents nested tags by two spaces per level Handles void elements such as br and img Does not execute or modify the markup Works on fragments as well as full pages
INPUT HTML to beautify *
0 chars0 words0 lines
Paste the source value for this specific transformation. Example: <main><section><h1>Trexmi</h1><p>Ready</p></section></main>
Ctrl / ⌘ + Enter
Beautified HTML Beautified HTML ready to review and copy.
About the tool

What HTML Beautifier does

The HTML beautifier takes minified or badly indented HTML and prints it with one tag or text run per line, indented two spaces per nesting level. It is meant for reading and debugging: view-source output, a minified template, an email snippet or markup copied from a CMS becomes a tree you can follow.

The tool does a straightforward, predictable job and does not try to be a full HTML parser. It does not validate the markup and does not fix errors, so an unclosed tag will simply show up as wrong indentation, which is often the quickest way to find it. To go the other way, use the HTML Minifier.

html beautifier turning one-line HTML into an indented tree
Minified HTML on the left, indented tree on the right.

How to use

  1. Paste the HTML. A full page or a fragment both work.
  2. Run the beautifier. Tags are split onto separate lines and indented by depth.
  3. Check the structure. Indentation that drifts to the right or snaps back to the left points to an unclosed or extra tag.
  4. Copy the result. Use it for reading or review; keep your original for production.
Built for the task

Why use HTML Beautifier?

Focused controls, predictable output, and a workflow designed around this exact transformation.

01

Readable structure

Nesting becomes visible, so you can see which element contains which.

02

Fast error spotting

Missing or extra closing tags show up as indentation that does not return to the left.

03

Markup is not executed

The tool treats HTML as text and never runs scripts from it.

04

Fragments welcome

You can beautify a single block, not only a complete document.

Useful answers

Questions about HTML Beautifier

Practical details about input, output, privacy, limits, and the best way to use this tool.

01 Does the HTML beautifier change my markup?

It changes whitespace only: tags and text are re-printed on separate lines. Attributes, tag names and text content are not rewritten. Because inline elements such as links and bold text are also placed on their own lines, the rendered spacing around them can differ slightly from the original.

02 Does it fix broken or unclosed tags?

No. It does not validate or repair HTML. Unclosed tags make the indentation drift, which helps you locate the problem. To repair a document, fix it in your editor or use a validator.

03 Is it safe to use on <pre>, <textarea> or inline scripts?

Be careful. Whitespace inside <pre> and <textarea> is meaningful, and the tool does not treat these elements specially. Use the result for reading, and do not deploy it blindly when the page contains such elements.

04 Does it format CSS and JavaScript inside the page?

No. Content inside <style> and <script> is treated as text. Use the CSS Beautifier or the JavaScript Beautifier for those parts.

05 What indentation does it use?

Two spaces per nesting level.

06 Are self-closing and void tags handled?

Yes. Void elements such as br, img, input, meta and link, as well as tags written with a trailing slash, do not increase the depth.

07 Can I use it for XML?

For well-formed XML, use the XML Formatter, which parses the document and reports errors with line and column.

Examples

A minified navigation list

Every opening tag adds one level, every closing tag removes one, and text sits on its own line.

Input
HomeAbout
Output
Home
    
  
  
    About

A full page with void elements

The doctype stays at the left, and void elements such as meta and br do not add a level.

Input
HiTextmore
Output
Hi
    
  
  
    
      Text
      
      more

What an HTML beautifier does

Browsers do not care how HTML is laid out, so templates, build tools and CMS exports often produce a single long line. The beautifier splits the markup into tags and text, puts each on its own line and indents it according to how deeply it is nested. The document is unchanged for the browser, but you can now read it.

When it helps

  • Debugging layout: see which wrapper a block really sits in.
  • Reading view-source: turn a minified page into something you can scan.
  • Cleaning CMS and email markup: inspect pasted snippets before editing them.
  • Code review: beautify two versions before comparing them.

Reading the result

Follow the left edge. A closing tag should line up with its opening tag. If the indentation keeps growing, a tag was never closed. If it snaps back too far, there is an extra closing tag. Optional end tags, such as an omitted </li> or </p>, are valid HTML but will also look like unclosed tags to this tool.

Limits to keep in mind

This is a lightweight formatter, not a parser. It does not validate, does not repair markup and does not preserve whitespace-sensitive blocks. Comments and the doctype are kept as separate lines. Check the result in a browser before using it anywhere other than for reading.

Related tools

Shrink markup with the HTML Minifier, format styles with the CSS Beautifier, scripts with the JavaScript Beautifier, or XML with the XML Formatter.

External reference

For the exact syntax rules, see the HTML Standard: syntax.