HTML Formatter & Minifier
Indent HTML by nesting level, or minify it. Pick 2 or 4 spaces, and keep or strip comments.
HTML formatters (beautifiers) put each tag on its own line and indent it by nesting level, so you can see which element contains which. That helps when you debug, review, or learn from HTML.
HTML minifiers do the opposite. They remove whitespace to make the file smaller, which is common on production sites.
Code review
Indent HTML so it's easier to review and debug
Learning
See how a page nests its elements
Production
Minify HTML to cut file size
Development
Clean up HTML pasted from WYSIWYG editors
What is HTML formatting?
HTML formatting (also called beautifying) puts each tag on its own line and indents it by nesting level. It makes generated or minified HTML readable again.
What is HTML minification?
HTML minification removes whitespace, comments, and line breaks to make the file smaller. The page loads faster, but the source becomes hard to read.
Should I use 2 or 4 space indentation?
Both are fine. 2 spaces is more compact and common in web projects. 4 spaces makes deep nesting easier to follow. Match whatever your project already uses.
Does minifying break the HTML?
Usually not, because browsers ignore most whitespace between tags. This minifier collapses every run of whitespace into one space, though, including inside <pre>, <textarea>, and inline scripts. An inline script that uses // comments will break once its lines are joined, so check those before you ship.
Private by default
Formatting and minification run in your browser. Your HTML is never sent to a server.
Related tools
JSON Formatter
Format JSON online in your browser. Paste or upload JSON to tidy it with 2 or 4 space indents, find syntax errors, minify it or browse it as a collapsible tree.
JavaScript to JSON
Convert JavaScript object literals to valid JSON
JSON Merge
Merge two JSON objects online with a deep or shallow strategy and choose how arrays combine. Useful for config files and API responses. Free, no signup.