HTML Formatter Online Free — Beautify & Indent HTML, Inline CSS, and JS
What's included
Features
About this tool
Format HTML Online Instantly — Beautify Minified HTML with Proper Indentation
You got a wall of minified HTML from a build tool, a CMS export, or a web scraper and you can't read it. Or you copied a template from documentation and the indentation is all over the place. Paste it here and click Format — it comes back with clean 2-space indentation in under a second.
This formatter handles the full range of real-world HTML: nested block and inline elements, void elements (br, img, input, meta, link, hr) that don't add indentation depth, self-closing tags with />, DOCTYPE declarations, HTML comment blocks, and deeply nested component trees. Works on complete HTML documents, partial fragments, component templates, email HTML — whatever you have.
What makes this different from basic HTML indenters: it also formats inline CSS and JavaScript. Most HTML formatters only indent the tags — they leave the contents of style and script blocks as raw unformatted text. This formatter detects every style block and applies CSS-specific formatting (rule blocks, property lists, selector grouping), and every script block and applies JavaScript brace-based indentation. The result is a completely clean, readable document end-to-end — not just the tags.
The history bar saves up to 15 timestamped snapshots of your formatting sessions. Format, edit, format again, and every version is available to restore with one click. Live line numbers stay in sync with the editor so you can reference specific lines in code reviews or bug reports.
Everything runs in your browser. No code is sent to any server. Safe for internal templates, client work, and any HTML you wouldn't want shared.
Step by step
How to Use
- 1Paste or upload your HTMLPaste your raw, minified, or unformatted HTML directly into the editor. You can also click Upload to load an
.html,.htm,.xml, or.svgfile from your computer, or drag and drop a file directly onto the editor area. The editor accepts full HTML documents, partial fragments, component templates, email HTML, and any other valid or near-valid markup. - 2Choose indent size (2 or 4 spaces)Use the 2 or 4 chip buttons in the toolbar to set your preferred indentation width before formatting. 2 spaces is the most common default. The setting also applies live to already-formatted output — switch between 2 and 4 and the result updates instantly without re-clicking Format.
- 3Click Format to beautifyClick the Format button. The output appears with clean indentation, properly nested tags, and formatted inline CSS and JavaScript blocks. Void elements —
br,img,input,meta,link,hr,area,base,col,embed,param,source,track,wbr— are handled correctly with no extra indentation step. - 4Use Minify to collapse the outputClick Minify to collapse the HTML to its smallest possible single-line form — all whitespace removed, inline CSS and JS compacted. Check Keep comments before minifying if you want HTML comment blocks preserved in the output. The minified result appears immediately and can be copied or downloaded.
- 5Use Find to search through the codeClick Find (or press
Ctrl+F/Cmd+F) to open the search bar. Type a query to highlight all matches in the editor. Use the up/down arrows to jump between matches and toggle Aa for case-sensitive search. The search bar works in both input and formatted output modes. - 6Copy, download, or restore from historyClick Copy to copy the full output to clipboard. Click Download to save it as
formatted.html. Click History to see up to 15 timestamped snapshots of previous format operations — click any entry to restore that version instantly. - 7Toggle line wrap for long linesClick Wrap in the toolbar to toggle word-wrap on long attribute lists or minified output. The live line-number gutter stays synced to the editor scroll position in both wrapped and unwrapped modes.
Real-world uses
Common Use Cases
Got questions?
Frequently Asked Questions
Paste the minified HTML into the editor and click Format. The entire document expands from a single line into properly indented, nested structure. Every opening tag increases indentation depth and every closing tag decreases it. Void elements (br, img, input, meta, link) are handled correctly without adding extra indentation depth. The result is ready to read, debug, or commit to version control.
Yes — this is what separates it from basic HTML indenters. Most online HTML formatters only indent the tags and leave style and script block contents as raw unformatted text. This tool detects every style block and applies CSS formatting (rule blocks, property indentation, selector spacing), and every script block and applies JavaScript brace-based indentation. The entire document is formatted end-to-end.
Yes. You don't need a complete HTML document with doctype, html, head, and body. Paste any fragment — a single div and its children, a navigation component, a form, a table, or a Vue/Angular/React template — and the formatter indents it correctly. It works on whatever structure is present, not on assumptions about a complete document.
Yes — this tool is completely free with no installation, no extension, no sign-up, and no file upload. Paste HTML, click Format, and copy the result. Works in Chrome, Firefox, Safari, and Edge on both desktop and mobile. Everything runs in your browser using JavaScript — no server involved.
Every time you click Format, the output is automatically saved as a timestamped chip in the history bar. Up to 15 entries are saved per session. Click any chip to restore that version — useful when you format, make edits, format again, and want to compare or go back to an earlier version. History is only kept in memory for the current session; closing the tab clears it.
No. All formatting runs in your browser using JavaScript. Your HTML is never transmitted over the network or stored anywhere. Safe for internal templates, proprietary component code, client work, and HTML you wouldn't want to share with a third-party service. Works fully offline once the page is loaded.
Yes, for most real-world imperfections. It handles missing closing tags, attributes without quotes, mixed case tag names, and other common issues. It applies best-effort indentation based on the tag structure it can detect. Severely mismatched tag hierarchies may produce unexpected indentation. For production code, validate with the W3C Markup Validator after formatting.
Yes. Click Upload to load an .html or .htm file from your computer, or drag and drop a file onto the editor. Click Download after formatting to save the result as a .html file. The filename matches the original uploaded file's name, or defaults to formatted.html for pasted content.