HTML Formatter

Tidy messy HTML into readable indentation — or minify it to one line — entirely in your browser.

How to use

  1. Paste or type HTML. It formats (or minifies) as you type — no button to click.
  2. Switch Format / Minify; pick 2 or 4 spaces. The indent control is disabled in Minify mode.
  3. Block elements are indented one level per depth, one per line. Inline content (text mixed with <a> or <b>) is kept exactly as written.
  4. Void elements (<br>, <img>, <input>…) need no closing tag and are preserved verbatim, including an optional />.
  5. Raw-text elements (<script>, <style>, <textarea>, <title>, <pre>) are copied character-for-character; nothing inside is parsed or reformatted.

Example

Input

<!DOCTYPE html><html><head><meta charset="utf-8"><title>Demo</title></head><body><div class="card"><h1>Hello</h1><p>Hi <b>there</b></p><ul><li>one</li><li>two</li></ul></div><script>const x=1;</script></body></html>

Output

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Demo</title>
  </head>
  <body>
    <div class="card">
      <h1>Hello</h1>
      <p>Hi <b>there</b></p>
      <ul>
        <li>one</li>
        <li>two</li>
      </ul>
    </div>
    <script>const x=1;</script>
  </body>
</html>

Inline content and <script>/<style> contents are kept verbatim; <meta> is a void element, preserved as written.

Limitations

  • Structural only: tag pairing, void elements, common implicit closes (li/td/tr/dt/dd/option/p/head) and nesting. No DTD/Schema validation.
  • Embedded JavaScript and CSS are not formatted — <script>/<style> contents are kept as-is. (Use the Code Formatter for those.)
  • Not all optional HTML5 end tags are inferred; genuinely malformed nesting is reported with line and column.
  • Inline/mixed content is deliberately not re-indented. <pre>/<textarea>/<title> contents are preserved verbatim.
  • No file upload, no URL parameters, no history, no account. Input never leaves your browser.

Other formatters and text tools in this toolbox.