HTML Formatter
Beautify and minify HTML with tag counts and quick copy/download actions.
- Beautify HTML
- Minify
- Tag Stats
- Copy
- Download
Choose an action to generate output.
Format real HTML syntax and review browser recovery points
Prettier parses and consistently reprints complete HTML documents or reusable fragments, with optional formatting for supported CSS and JavaScript inside style and script elements.
A standards-oriented HTML5 parser supplies syntax recovery locations, while separate practical audits check common document, accessibility, identifier, link, image, and active-content patterns.
How to format, preview, or minify HTML
- Paste markup, open or drop a local HTML file up to 2 MB, or load a document, fragment, form, embedded-code, preview-safety, or markup-error example.
- Choose Document or Fragment and configure indentation, print width, HTML whitespace sensitivity, embedded-code formatting, attributes, brackets, and line endings.
- Choose Minify and explicitly select conservative or compact whitespace plus optional comment, redundant-attribute, optional-tag, and embedded-code optimizations.
- Review exact output, the sanitized sandbox preview, parser diagnostics, practical audits, document metrics, and line changes.
- Copy or download the exact output, or return it to the source editor for another controlled pass.
Keep output exact while making preview intentionally safe
- Use grammar-aware formatting so raw-text elements, attributes, comments, inline text, SVG, templates, and embedded code are not indented with fragile tag expressions.
- Distinguish complete documents from fragments so doctype, language, title, charset, viewport, and primary-heading checks appear only when relevant.
- Generate preview from the exact result, then remove scripts, event handlers, forms, embeds, remote resources, and risky CSS URLs only inside the sandboxed preview copy.
- Keep conservative whitespace and all destructive minifier choices disabled by default, with explicit controls and production-testing guidance.
- Read, parse, format, minify, audit, preview, copy, and create downloads locally without uploading source or requesting remote URLs.
HTML Formatter FAQ
Does the formatter repair invalid HTML?
It can reprint markup that HTML parsers recover, but it reports recovery points and does not promise to repair every standards or application problem.
What is the difference between Document and Fragment?
Document mode audits page-level requirements such as doctype, language, title, charset, viewport, and h1. Fragment mode formats reusable markup without requiring them.
Does preview execute scripts or load remote resources?
No. Preview uses a sandbox and removes scripts, event handlers, forms, embedded frames, remote resource URLs, and risky CSS URLs.
Does preview change copied output?
No. Copy and download use the exact text shown in Output. Sanitization is applied only to the preview copy.
Which minify mode is safest?
Conservative whitespace with optional removals disabled. Compact whitespace, optional-tag removal, and embedded-code minification require application testing.
Is this a complete W3C validator?
No. It reports HTML5 parser findings and selected practical audits. Use a dedicated conformance checker for exhaustive standards validation.
Are HTML files uploaded?
No. File reading and every transformation happen locally in the browser.
Help us improve this tool
Please share what we should improve, add, or fix. You can write in the language you are comfortable with. We only save your suggestion and IP address to prevent misuse.