HTML Formatter
Turn compressed or messy HTML into neatly indented markup that is easy to read and review. Blocks where whitespace matters, such as pre and textarea, are left exactly as they are, and script and style content can be kept untouched. Your HTML is handled purely as text: it is never displayed and its scripts are never run.
Format Your HTML
Formatted HTML
Result
How to Use the HTML Formatter
- Paste your HTML into the box.
- Pick the indentation, optional line wrapping and how inline script and style blocks should be treated.
- Press Format.
- Copy the formatted markup or download it as formatted.html.
About This Tool
Front-end developers reading minified pages, content editors cleaning up pasted markup, and anyone comparing two versions of a template.
Input: HTML ยท Output: Formatted HTML (.html).
Features and Limitations
Features
- Indentation with 2 spaces, 4 spaces or tabs and optional wrapping at 80 or 120 characters.
- pre and textarea content is never changed; script and style blocks are kept as written unless you choose to beautify them.
- Powered by the open-source js-beautify library, bundled with this site (no external requests).
- Safe: your markup is never rendered and nothing in it is executed.
Limitations
- It is a formatter, not a validator: broken HTML is reformatted on a best-effort basis and no errors are reported. Use a validator to find markup problems.
- Re-indenting can add whitespace between inline elements, which may change how a page looks in rare cases. Review the result before replacing production code.
- Template syntax such as {{ }}, <% %> or PHP is not understood and may be wrapped oddly.
- Very large documents can take a few seconds.
- Results are computed in your browser; nothing you enter is sent to a server.
Example
- One
- Two
- line with each
- indented underneath it.
Frequently Asked Questions
Does the formatter run the scripts in my HTML?
No. The HTML is processed as plain text. Nothing is rendered, loaded or executed.
Why are my pre blocks not indented?
Whitespace inside pre and textarea is significant, so those blocks are copied exactly. Indenting them would change what the browser displays.
Can formatting change how my page looks?
Occasionally. Adding line breaks and spaces between inline elements (for example two links in a row) can introduce a visible gap. Compare the page before and after if the layout is delicate.
How do I shrink HTML instead?
Use the HTML Minifier, which removes comments and unneeded whitespace.
Is the code uploaded?
No. Formatting happens in your browser.
Related Tools
More like this: all Format & Validate tools, all Developer & Web tools or the TinySandy home page.