HTML Formatter

Re-indent messy or minified HTML so the structure is readable again. Fast, free, and built for simple browser-based workflows.

Instant
Processing
Private
Browser First
Free
No Signup

HTML Formatter

Popular

Paste your HTML above, then click Format HTML.

Advertisement

728 x 90 In-Content Ad

About This Tool

HTML Formatter is a free online tool that re-indents messy or minified markup so its structure is readable again. Paste the HTML, choose an indent size, and every tag is placed on its own line at the depth where it actually sits -- nothing to install and no build step to run.

It earns its keep when markup arrives unreadable: a minified page you need to inspect, an email template pasted out of a CMS as one endless line, a snippet copied from a browser's View Source, or a colleague's file with three different indent styles in it. Nesting you cannot see is how a stray closing tag survives review for a week.

Everything runs inside your browser and your markup is never uploaded to a server. That matters when the file is a client's landing page, an unreleased template, or anything with internal URLs sitting in a script tag. The formatted result stays on your device unless you choose to copy or download it.

Re-indents nested tags so the page structure is visible at a glance
Choose 2 spaces, 4 spaces, or a tab for each indent level
Leaves pre, textarea, script and style contents exactly as they were
Keeps void tags such as br and img on a single line
Tells you how many lines the formatted markup runs to
Runs entirely in your browser -- nothing is uploaded

How to Use HTML Formatter

1

Paste your HTML

Drop messy or minified markup into the Unformatted HTML box. Anything from a single snippet to a full page works.

2

Pick an indent size

Choose 2 spaces, 4 spaces, or Tab from the Indent Size menu so the output matches the file you are pasting it back into.

3

Format the markup

Click Format HTML. Each tag moves onto its own line at its nesting depth, and the line count appears above the result.

4

Take the result

Click Copy for the clipboard, or Download to save the markup as formatted.html. Clear empties both boxes.

Frequently Asked Questions

Is this tool completely free?

Yes! All our tools are 100% free to use with no hidden costs, no registration required, and no credit card needed.

Is my data safe and private?

Absolutely. All tools run entirely in your browser (client-side). Your data never leaves your device and is not sent to our servers.

Can I use this tool offline?

Yes, once the page is loaded, the tool will continue to work even if you lose internet connection since it runs in your browser.

Is there a character limit?

There is no strict character limit, but very large amounts of text (100,000+ characters) may slow down your browser.

Can I use this for commercial projects?

Yes! All our tools are free for both personal and commercial use.

Does formatting HTML change how the page renders?

In almost every case, no. Indentation is whitespace between tags, and browsers collapse it. The exceptions are inline elements where a single space is visible, and the contents of pre, textarea, script and style -- which this tool deliberately leaves exactly as it found them.

Which indent size should I choose?

Two spaces is the usual default for HTML and stops deeply nested markup drifting off the right edge of the screen. Pick 4 spaces or Tab when the project you are pasting into already uses them, so the file stays consistent with the code around it.

Why is the text inside my pre block left alone?

Because whitespace inside pre, textarea, script and style is meaningful -- re-indenting it would change what the visitor sees or break the code. The formatter spots those four elements, copies their contents through untouched, and resumes indenting after the closing tag.

Can it repair broken or unclosed HTML?

No. It formats markup, it does not validate or fix it. An unclosed tag leaves everything after it indented one level deeper than expected, which is often the fastest way to spot where the missing tag belongs -- but you still add it yourself.

Can I format minified HTML copied from a live site?

Yes, and it is the most common reason to use it. Paste the single-line source from View Source or your browser's DevTools, click Format HTML, and every tag lands on its own line at the right depth so you can read how the page is built.

Does it handle PHP or template tags mixed into the HTML?

Partly. Anything opening with a doctype or a PHP tag is placed on its own line without changing the indent level, so those survive intact. Curly-brace template syntax is treated as ordinary text and passes through unchanged, though it will not affect indentation either.