HTML Formatter

Next

Paste markup and this browser-local formatter places tags and text on indented lines. Choose two or four spaces, inspect the result, and copy it when it is useful for reading or reviewing. Your HTML stays in this browser session.

Format HTML in three steps

  1. 1

    Paste markup

    Add the HTML you want to inspect. Nothing is sent to the server.

  2. 2

    Choose indentation

    Use two or four spaces for each nesting level.

  3. 3

    Review and copy

    Check the formatted text before you use it elsewhere.

What this formatter does

The formatter is a small structural reader, not a full HTML parser. It puts opening tags, closing tags, comments, declarations and text on separate lines, then applies the selected indentation. Standard void elements such as <img>, <br> and <meta> do not create another nesting level.

Blocks beginning with <pre>, <code>, <textarea>, <script> or <style> are kept together as supplied. The tool does not validate markup, repair unclosed tags, wrap attributes, rewrite self-closing syntax, minify code, or understand a page’s CSS and JavaScript semantics.

Formatting can change whitespace around ordinary text nodes. Treat the output as a readable working copy and compare it before saving a whitespace-sensitive template or publishing it. For validation, use an HTML validator; for byte-preserving transformations, use an editor or formatter designed for your project.

Frequently Asked Questions

No. Formatting and copying happen in your browser. Funnel steps keep the current input only in session storage.

No. It only applies simple indentation and cannot tell whether markup is valid or semantically correct.

No. Complete script and style blocks are kept as supplied.

Related Tools