In shortPaste your HTML and click Format: the formatter re-indents every tag, puts each block element on its own line and also tidies inline <style> and <script> blocks. Choose 2 spaces, 4 spaces or tabs.
How to use the HTML formatter
- Paste your HTML. Paste the code or open an .html file. A messy sample is loaded so you can see the result.
- Pick the style. Choose indentation, line wrapping and how attributes are laid out.
- Format. The formatted HTML appears on the right as you type; click Format HTML to re-run.
- Copy or download. Copy the result or download it as formatted.html.
Why format HTML?
HTML that's been minified, generated by a CMS, exported from an email builder or pasted from a website is often one enormous line. Formatting (also called beautifying or pretty-printing) puts each element on its own line and indents children inside their parents, so you can see the structure, find the bit you need and spot unclosed tags.
Before and after
<ul><li>One</li><li>Two</li></ul>
becomes
<ul>
<li>One</li>
<li>Two</li>
</ul>
Does formatting change how the page looks?
Almost never. Browsers ignore extra whitespace between block elements. The formatter leaves <pre>, <textarea> and <code> content alone, because whitespace matters there. The one edge case is whitespace between inline elements (like two <span>s or inline-block buttons), which can add or remove a single space.
Formatting vs minifying vs cleaning
| Tool | Changes | Use for |
|---|---|---|
| Formatter | Whitespace only — adds indentation | Reading and editing code |
| Minifier | Whitespace and comments — removes them | Smaller files in production |
| Cleaner | Tags and attributes — removes styles, spans, junk | Pasted or exported content |
The formatter is built on js-beautify, the open-source engine used by VS Code and many IDEs.
Private by design: this tool runs entirely in your browser. Nothing you paste or open is uploaded to a server.
Frequently asked questions
How do I format HTML code online?
Paste it into the box on this page. The formatted, indented version appears on the right instantly; copy it or download it.
Does it format CSS and JavaScript inside the HTML?
Yes. Code inside <style> and <script> tags is indented too.
Can I use tabs instead of spaces?
Yes — choose Tabs in the Indent menu. You can also pick 2 or 4 spaces.
Will formatting break my page?
No for almost all pages. Only whitespace changes, and <pre>/<textarea> content is preserved. In rare cases a space between inline elements can change.
Is there a size limit?
No fixed limit — it runs in your browser. Multi-megabyte files take a second or two.