We use essential storage to make the site work. If you accept, we also use Google Analytics to understand usage and Google AdSense to show ads, which may set cookies. You can change your choice any time with Cookie settings in the footer. Privacy Policy
HTML Formatter
Beautify and indent any HTML — minified pages, scraped markup, email templates. Configurable indent width. 100% browser-based. 100% free and private.
How to use
Paste HTML — Drop in minified, scraped, or messy HTML — any size.
Set Indent — Choose 2, 4, or any number of spaces for indentation.
Copy Clean Output — Use the beautified result in your editor, docs, or commit.
Frequently asked questions
Does the formatter modify my HTML structure?
No. It only adjusts whitespace and indentation — every tag, attribute, and value stays exactly as you provided.
Does it work with templating syntax?
Yes for most cases: Handlebars, Mustache, JSX-like expressions, Twig, Blade are preserved as text. Very complex template-only files may need a language-specific formatter.
Will it strip my comments?
No, comments are preserved and indented alongside neighbouring tags.
Is anything uploaded?
No — every transformation runs in your browser via plain JavaScript.
Will it change my markup's meaning?
No — formatting only adjusts whitespace. Rendered output is identical.
Does it fix invalid HTML?
It will flag issues, but it does not silently auto-correct (which would risk hiding bugs).
What about embedded `<script>` and `<style>`?
Indented as a block; internal JS/CSS formatting is best done with dedicated formatters.
Can I choose tabs or spaces?
Yes — switch between 2-space, 4-space, and tabs.
Is my HTML uploaded?
No. All parsing runs locally.
The HTML Formatter turns minified or messy HTML into clean, properly indented markup. Perfect for reviewing scraped pages, debugging email templates, or beautifying a build output.
Features
Pure JavaScript tokenizer — no external dependencies.
Preserves comments, DOCTYPE, and templating syntax as-is.
Inline tags (a, span, strong, em) stay on the same line for readability.
Configurable indent width.
Privacy
All formatting happens inside your browser. The tool never uploads your markup.
Related free tools
XML Formatter & Minifier — Beautify or minify any XML — SOAP, RSS, SVG, sitemap. Browser-based parser.
XML to JSON Converter — Parse any well-formed XML into a clean JSON tree with attributes and arrays.
JSON to XML Converter — Convert JSON to well-formed XML — supports attributes, custom root, declaration.
CSV Viewer — Open CSV or TSV files in your browser — sort, search, paginate, export filtered view.
JSON to CSV Converter — Convert JSON data to CSV format. Export to spreadsheets easily.
CSV to JSON Converter — Convert CSV data to JSON format. Useful for API development.
JSON Formatter — Format, beautify, or minify JSON with customizable indentation.
JSON Validator — Validate JSON syntax and find errors with line and column numbers.
HTML Minifier — Compress HTML by removing comments, whitespace, and line breaks.
CSS Minifier — Minify CSS by stripping comments, whitespace, and unnecessary characters.
JavaScript Minifier — Compress JavaScript by removing comments, whitespace, and empty lines.
Base64 Encoder/Decoder — Encode text to Base64 or decode Base64 back to text. UTF-8 support.