HTML Formatter & Beautifier Online — Free, Private
Output
Paste minified or messy HTML into the input box, then click Format to re-indent it with each element on its own line, or Minify to strip the whitespace back out. It understands void tags like <br> and <img>, leaves <script>, <style>, and <pre> content untouched, and runs entirely in your browser.
How it works
- 1 Paste your HTML into the input Drop in a one-line minified page, a copied email template, or any tangled markup. The tool reads it tag by tag and shows a live status as you type.
- 2 Click Format or Minify Hit Format to indent the markup two spaces per nesting level, or Minify to collapse it back into compact HTML with the gaps between tags removed.
- 3 Copy the result Click Copy output to send the formatted or minified HTML to your clipboard in one click.
Your data stays private
All processing happens entirely in your browser. No files, text, or data are ever sent to our servers. You can disconnect from the internet and this tool will still work.
Frequently asked questions
- How does the HTML formatter work?
- It parses the markup in JavaScript, tracks nesting on a stack, and puts each element on its own indented line. Void elements such as br, img, and input are handled without a closing tag, and it applies HTML's implied-close rules for list items, table rows, and options.
- Does it change the content of my script and style tags?
- No. Anything inside <script>, <style>, <pre>, and <textarea> is treated as raw text and passed through exactly as written, so your JavaScript, CSS, and preformatted blocks are never reflowed or re-escaped.
- Can it fix broken or unclosed HTML?
- It is lenient rather than strict — it will still format markup with missing closing tags and shows a warning listing what looked off, but it does not rewrite your HTML to make it valid. Use it to read and tidy, not to auto-repair.
- Can I minify HTML too?
- Yes. Click Minify to remove the whitespace between tags and collapse runs of spaces in text, producing a smaller single-line version while keeping script, style, and pre content intact.
- Is my HTML private?
- Your markup never leaves your device. All parsing and formatting happen in JavaScript inside your browser tab, with no network requests — so it keeps working even offline.
- What indentation does it use?
- Two spaces per nesting level, which matches the default used by Prettier and most modern style guides. Nested children sit two spaces deeper than their parent element.