HTML formatter
Runs entirely in your browser. Your files and data never leave your device.
About this tool
Paste an HTML document or snippet and this tool will pretty-print it with proper indentation, or strip it down to a single compact line.
What happens to malformed markup?
Nothing breaks. The formatter uses js-beautify, which works on tokens rather than parsing a strict DOM tree, so unclosed tags, mismatched closing tags, or markup missing a <head> all still get indented instead of throwing an error. You can choose 2-space, 4-space, or tab indentation. Minifying works the same way: it’s a set of text passes that strip comments and collapse whitespace between tags, and it leaves unclosed or badly nested markup alone rather than trying to fix it. Either way, you can clean up rough HTML without hunting down every broken tag first.
One thing minifying does take care to protect is the content of <pre>, <textarea>, <script>, and <style> elements. Whitespace inside those tags is either meaningful (a <pre> block’s line breaks) or actual code that collapsing could break (inline JavaScript or CSS), so the tool skips those blocks and only touches whitespace between ordinary tags.
Does any of this get uploaded?
No. Formatting and minifying both run entirely in your browser using the js-beautify library loaded into the page, nothing is sent to a server. That means page templates, email markup, or scraped fragments with real customer content can go through this tool without leaving your machine.
What’s it useful for?
Common cases are tidying up a minified page saved from view-source so you can actually read it, shrinking an HTML email template’s file size before sending, or reformatting a component’s markup to a consistent indent width before a code review. It also works the other direction: if you’ve got hand-written HTML with inconsistent spacing and want a single compact line to paste into a config value or a data-* attribute, minifying does that in one step.
Switching between the two modes is also a quick way to compare two versions of a page, since diffing tools work much better on consistently formatted markup than on a mix of indentation styles. If you maintain a static site or a component library, running generated or copy-pasted HTML through this before committing it keeps the whole codebase looking consistent, even when the source pieces came from different places.