HTML Formatter
Format and beautify HTML markup with sensible defaults. Everything runs in your browser, so your data never leaves the page.
About this HTML formatter
This is a free online HTML formatter. Paste any HTML document (or fragment) into the input panel and you'll get a cleanly indented, readable version in the output panel. Block-level elements get their own line, inline elements stay inline, and the existing structure of the markup is preserved.
Features
- Format HTML with 2 spaces, 4 spaces, or tab indentation.
- Wrap long lines at a chosen column, or leave them unwrapped.
- Embedded
<script>and<style>blocks are formatted as JavaScript and CSS. - Preserve attributes, comments, conditional comments, and doctypes.
- Copy the result or download it as an
.htmlfile.
How it works
The tool uses the open source js-beautify library, loaded into your browser on first use. It tokenizes the markup, understands which elements are block versus inline, and pretty-prints accordingly.
Privacy
Your HTML never leaves your browser. The whole tool runs locally as JavaScript on this page, so you can safely paste production templates, internal documents, or anything else without it touching a server.
Frequently asked questions
Does this tool send my HTML anywhere?
js-beautify library is fetched once from a public CDN, but your HTML text is never uploaded.