All tools

HTML Formatter & Minifier

Indent HTML by nesting level, or minify it. Pick 2 or 4 spaces, and keep or strip comments.

Browser onlyYour input is processed in this browser and is not sent to SpeedyTools servers.
Share:
Options
HTML Input
Formatted Output
About HTML formatting

HTML formatters (beautifiers) put each tag on its own line and indent it by nesting level, so you can see which element contains which. That helps when you debug, review, or learn from HTML.

HTML minifiers do the opposite. They remove whitespace to make the file smaller, which is common on production sites.

Features
Indent HTML by nesting level
Minify HTML by collapsing whitespace
Choose indent size (2 or 4 spaces)
Keep or strip comments when minifying
Runs in your browser
One-click copy output
Common use cases

Code review

Indent HTML so it's easier to review and debug

Learning

See how a page nests its elements

Production

Minify HTML to cut file size

Development

Clean up HTML pasted from WYSIWYG editors

Frequently asked questions

What is HTML formatting?

HTML formatting (also called beautifying) puts each tag on its own line and indents it by nesting level. It makes generated or minified HTML readable again.

What is HTML minification?

HTML minification removes whitespace, comments, and line breaks to make the file smaller. The page loads faster, but the source becomes hard to read.

Should I use 2 or 4 space indentation?

Both are fine. 2 spaces is more compact and common in web projects. 4 spaces makes deep nesting easier to follow. Match whatever your project already uses.

Does minifying break the HTML?

Usually not, because browsers ignore most whitespace between tags. This minifier collapses every run of whitespace into one space, though, including inside <pre>, <textarea>, and inline scripts. An inline script that uses // comments will break once its lines are joined, so check those before you ship.

Private by default

Formatting and minification run in your browser. Your HTML is never sent to a server.