HTML Formatter

Indent messy markup or minify it, with void elements and pre blocks handled correctly.

Mode
Indent
HTML

Void elements do not add indentation, and the contents of pre, textarea, script and style are left exactly as written.

Result

How to Format HTML

1

Paste your markup

A full page, a component, or a fragment copied out of a template. Minified markup with everything on one line is exactly what this is for.

2

Beautify or minify

Beautify indents each element by nesting depth, with two or four spaces. Minify removes comments and the whitespace between tags to make the payload smaller.

3

Copy the result

Void elements such as img and br do not open a new level, and the contents of pre, textarea, script and style are passed through untouched so nothing is corrupted.

Features

Beautify with two or four space indentation
Minify by removing comments and inter-tag whitespace
Void elements correctly treated as self-closing
Contents of pre, textarea, script and style preserved exactly
Doctype, comments and processing instructions handled
Works on fragments as well as complete documents
Runs entirely in your browser, nothing is uploaded
Free with no sign-up and no size limit

Frequently Asked Questions

No, it formats. Unlike the XML formatter, HTML tolerates unclosed tags by design, so the tool lays out what you give it rather than refusing. Use a validator if you need correctness checked.

No. Anything inside pre, textarea, script or style is passed through exactly as written, because reindenting those would change what the page displays or what the code does.

Because it is a void element and cannot contain anything. Void elements such as img, br, input and meta never open a nesting level, which is what keeps the output correct.

No. Formatting runs in your browser, so templates and client work stay on your machine.

Usually less than people expect once gzip is in play, since compression already handles repeated whitespace well. It is most worthwhile for markup embedded in a string, such as an email template.

No. Attributes are left exactly as you wrote them, including their order, quoting and spacing. Only the position of tags on the page changes.

Yes, including the doctype and comments. Very large documents are held in memory and reformatted on each keystroke, so extremely big pages will feel slow.

Yes, completely free with no sign-up.

Need a Custom Tool or Application?

We build production-grade web applications, SaaS platforms, and developer tools. Let's talk about your project.

or book a free call