An HTML formatter (also called an HTML beautifier) takes messy HTML and lays it out neatly. A
<li> gets its own line, one step further in than its <ul>. Short inline tags
like <b> stay in their sentence. Your words and tags don’t change, only the spaces and line
breaks around them.
Most pages look the same afterwards. The ones to check are pages where your CSS makes that spacing visible, like
menu items set to inline-block (see CSS display) or text with
white-space: pre-wrap.
Why bother? Because you’ll spend way more time reading HTML than writing it. Code copied from a CMS, an email
template or the browser’s “View source” often arrives as one giant line. With proper indentation you can see at
a glance which <div> closes where, spot a tag that’s in the wrong place, and review changes
without squinting. It also keeps a team’s code looking the same, no matter who wrote it.
It works the other way too. Switch to Minify and the tool strips comments and extra
whitespace for a smaller file. If that’s the main job, the HTML Minifier also shows
the gzipped size. Everything runs in your browser and your code is never uploaded.
How to Format HTML Online
Five short steps. Paste the examples into the tool above and watch what happens.
Step 1 Paste or Open Your HTML
Get your code into the left panel. Pick whichever is easiest:
Paste it: copy HTML from your editor, a CMS, an email or a web page’s source, and paste it in.
Open a file: click the upload button, or drag an .html file onto the tool.
Click Sample: loads a small, messy page so you can see the formatter in action right away.
There’s no Format button to hunt for. The right panel updates a moment after you stop typing.
Try it: one long line becomes readable
Before:
<divclass="card"><h2>Coffee</h2><p>Fresh, <b>hot</b> and strong.</p><ul><li>Small</li><li>Large</li></ul></div>
After (2 spaces):
<divclass="card"><h2>Coffee</h2><p>Fresh, <b>hot</b> and strong.</p><ul><li>Small</li><li>Large</li></ul></div>
💡 See how <b>hot</b> stayed inside its sentence? If it moved to its own
line, you could end up with an extra space around the word. Here the text still reads “Fresh, hot and strong.”
Step 2 Pick Your Indent
Use the indent menu above the output to choose 2 spaces, 4 spaces or
Tab. Two spaces is a common choice for HTML. If your project already has a style, match it.
This only indents your code. To indent text on the page itself, see how to indent text in HTML.
Long paragraphs can run far off the right side of your screen. Set Wrap to 80 or 120 and
the formatter breaks lines that are longer than that, where it can. It won’t split a word, so one very long
URL can still stick out. Browsers normally show a line break inside a paragraph as a space. Leave it on
Off if you’d rather not wrap, or if your CSS shows line breaks.
Try it: wrap at 80 characters
Before:
<p>HTML formatters keep inline tags like <ahref="/docs">links</a> on the same line as their text, so long paragraphs can get really wide.</p>
After (wrap at 80):
<p>HTML formatters keep inline tags like <ahref="/docs">links</a> on the same
line as their text, so long paragraphs can get really wide.</p>
Step 4 Keep Your Blank Lines
By default the formatter removes the empty lines between your tags. If you use blank lines to separate
sections of your page, tick Keep blank lines. Where you had one or more empty lines, you’ll get exactly one.
Switch the toggle to Minify when you want a smaller file. Normal comments go away, along with
extra whitespace. A single space stays between words and inline tags, like the one before
<b> in the example below. Text inside <pre> and
<textarea> stays as it is. Code inside <script> and
<style> isn’t minified, only trimmed at the start and end. The status bar shows how much
smaller the file got.
Try it: minify a menu
Before (153 bytes):
<!-- Main menu --><ulclass="menu"><li><ahref="/">Home</a></li><li><ahref="/blog">Blog</a></li></ul><p>Made with <b>love</b> and coffee.</p>
After (124 bytes, 19% smaller):
<ulclass="menu"><li><ahref="/">Home</a></li><li><ahref="/blog">Blog</a></li></ul><p>Made with <b>love</b> and coffee.</p>
Copy: puts the result on your clipboard in one click.
Download: saves the result as an .html file.
Next step: paste the result into the HTML Viewer to see the page, or
into the HTML Editor to keep working on it with CSS and JavaScript.
💡 A formatter fixes spacing, not mistakes. If a tag is missing or misspelled, the indentation usually looks
“off” around it, which is a great clue. To look for common mistakes, use the HTML Validator.
To repair broken tags, use the HTML Fixer. To strip out things like inline styles
and empty tags, use the HTML Cleaner.
Frequently Asked Questions
Will formatting change how my page looks?
Usually not. Format adds line breaks where browsers normally ignore them, like between a </li> and the next <li>. Text inside <pre> and <textarea> keeps its spacing. Your CSS can still make other spacing show. Say your menu items use display: inline-block. Format can add a small gap between them, and Minify can remove one. Text with white-space: pre or pre-wrap can lose its line breaks too. If your CSS does either of these, check the page before you publish it.
Does it format the CSS and JavaScript inside my HTML?
Yes, Format also indents the code inside <style> and <script> tags. For example, <style>h1{color:green}</style> becomes a small block, with color: green on its own line. Inline styles and onclick code stay as you wrote them. If your CSS or JavaScript is in a separate file, use the CSS Formatter or the JavaScript Formatter.
Should I use tabs or spaces?
Whatever your team already uses. Two spaces works well for HTML because nested tags add up fast. Four spaces is easier to scan if your markup is shallow. Tabs let everyone pick their own width in their editor. The important part is being consistent within a project.
What is the difference between Format and Minify?
Format is for people: it puts each block tag on its own line and indents it, so you can read and edit the code. Minify is for browsers: it removes most comments and extra whitespace, so the file is smaller. Format while you work, and minify the copy you ship if your build tools don’t already do it.
Is my HTML uploaded anywhere?
No. The formatting and minifying happen right here in your browser. Your code never leaves your computer, so it’s fine to paste private or work code.
Does it fix broken HTML?
No. A formatter only changes spacing and indentation, it doesn’t close missing tags or fix typos. The good news is that clean indentation makes those mistakes much easier to spot. To find them for you, run your code through the HTML Validator, or let the HTML Fixer repair them.
Why are comments gone after I click Minify?
Removing comments is part of minifying, since browsers skip them anyway. Old Internet Explorer conditional comments like <!--[if IE]> are kept because they can change what the page does. Switch back to Format and your comments are still there, because the original code on the left is never changed.
How much HTML can I paste?
Up to 5 MB, which is far bigger than almost any real page. Small files update a moment after you stop typing. Big ones take longer, depending on your device, so the tool waits a bit more before it reformats them.