HTML Formatter & Minifier
Beautify HTML with proper indentation, or minify it to reduce size — runs entirely in your browser.
Drop an .html file here, or click to upload
Ctrl + Enter to format
Format vs. minify — when to use each
Format (beautify) — adds consistent indentation and line breaks to make HTML human-readable. Use this when inspecting third-party markup, debugging rendered HTML from DevTools, or reviewing server-rendered templates. The output is functionally identical to the input; only whitespace changes.
Minify — removes unnecessary whitespace, comments, and optional closing tags to reduce file size. Use this in production where every kilobyte affects page load time. Minified HTML is not meant for humans to read directly — keep the unminified source in version control and minify as part of your build step.
HTML formatting conventions
This formatter uses 2-space indentation, matching the most common convention in web projects:
- Block-level elements (
div,section,article,main, etc.) get their own line and indent their children. - Inline elements (
span,strong,em,a) may remain inline within their parent's line when short. - Void elements (
br,hr,img,input,meta,link) are self-closing by convention. - Attributes are preserved as-is; attribute sorting is not applied.