HTML Formatter & Beautifier
Beautify or minify HTML. Configurable indent, line wrap, and inline-tag handling — all in your browser.
Beautify
Add proper indentation, line breaks, and optional line wrapping. Powered by js-beautify under the hood.
Minify
Strip comments and collapse whitespace between tags. <pre>, <textarea>, <script>, and <style> blocks are preserved verbatim.
Private
Formatting runs in your browser. Your markup — including inline scripts and internal URLs — never leaves your device.
Why format HTML at all?
Minified markup is impossible to scan for missing tags or wrong nesting. A pretty-printed document with consistent indentation makes structural mistakes obvious — an extra level of indentation almost always means a missing closing tag, and a missing one means an extra. The same logic applies to code review: a beautified file produces a clean line-by-line diff that reviewers can actually read.
When to minify
Minify only the version you ship — never the version you keep in version control. Static-site generators and modern bundlers usually minify HTML automatically at build time. This tool is useful for one-off cases: inline HTML inside an email template, a snippet you're pasting into a CMS that has a size limit, or a quick before/after to see how much whitespace was hiding in a file.
Things the beautifier won't touch
Contents of <pre>, <textarea>,<script>, and <style> are kept as-is so significant whitespace and embedded code are preserved. Inline phrasing tags (<a>, <strong>, <em>, <span>) stay on the same line as the surrounding text by default — splitting them would introduce visible spaces in the rendered output.
Frequently asked questions
›What does an HTML formatter do?
It rewrites HTML so that tags are properly indented, attributes are aligned, and the document is easy for a human to read. The structure and rendered output of the page do not change — only whitespace between tags is added or removed.
›Beautify vs minify — what's the difference?
Beautify adds line breaks and indentation so the document is readable in an editor or pull request review. Minify does the opposite: it strips comments, removes whitespace between tags, and collapses runs of spaces inside text to shrink the file before sending it over the network.
›Does minifying break anything?
Not for normal HTML. The minifier preserves <pre>, <textarea>, <script>, and <style> blocks exactly — whitespace inside those is meaningful, so it is left untouched. Conditional comments (<!--[if IE]> style) are also preserved.
›What indentation options are supported?
Two spaces (the de-facto web standard), four spaces (common in older PHP and Java templates), or a literal tab character. Pick whichever your editor and team conventions use.
›Can I wrap long lines?
Yes. Set a wrap width of 80 or 120 characters and the beautifier will break long attribute lists and text content at the nearest safe boundary. Set 'No wrap' to keep each tag on a single line regardless of length.
›Will it fix invalid HTML?
No — it formats whatever you paste. If a tag is unclosed or attributes are malformed, the output will still be malformed, just better-indented. Use a dedicated HTML validator (like the W3C Markup Validator) when you need correctness checking.
›Does it preserve inline elements like <a>, <span>, and <strong>?
Yes, when 'Keep inline tags on one line' is on. The beautifier knows the standard list of inline elements and avoids splitting them across multiple lines, which prevents accidental whitespace appearing between words in the rendered page.
›Is my HTML sent to a server?
No. Beautification and minification run entirely in your browser using js-beautify. Your markup — including any inline scripts, internal URLs, or templating tokens — never leaves your device.
›Can I format JSX or Vue templates with this?
Plain HTML in JSX and .vue templates formats fine, but JSX-specific syntax (curly-brace expressions, self-closing custom components) is not understood — use Prettier with the appropriate plugin for those. This tool is purpose-built for standard HTML markup.
More free developer tools
Part of our growing tool belt — all client-side, all free.
JSON Formatter & Beautifier
Format, beautify, minify and validate JSON with sort keys, ASCII escape, and tree view.
Open toolJSON Validator
Strict JSON validator with precise error location, lint hints, structure stats, and duplicate key detection.
Open toolJSON Viewer
Interactive JSON tree explorer with filter, copy-path, expand/collapse all, and colour-coded types.
Open tool