HTML Minifier / Beautifier

Prettify HTML with Prettier (HTML parser, tab width 2 or 4, print width 100) or minify with html-minifier-terser: collapse whitespace, strip comments, short doctype, tighten boolean and redundant attributes, minify inline CSS and JS. Load sample, copy, or download document.html — all client-side.

htmlminifyweb

Category: Code & Developer Tools

Beautify uses Prettier (HTML). Minify uses html-minifier-terser with whitespace collapse, comment removal, short doctype, and optional CSS/JS minification inside tags. Review output before production use.

Paste HTML, then Beautify or Minify.
Result appears here…

Beautify vs minify HTML

Beautifying reformats markup with readable indentation and wrapping so you can review templates, email HTML, or scraped snippets. Minifying removes extra whitespace and comments, shortens the doctype, and can shrink inline CSS and JavaScript to reduce file size for faster page loads. Both operations are useful at different stages of development — use Beautify for clarity and Minify when you need a smaller payload.

How this HTML tool works

Paste HTML into the input area. Beautify runs Prettier’s standalone formatter with the HTML parser and your chosen tab width (2 or 4 spaces) and a 100-character print width. Minify runs html-minifier-terser with conservative whitespace collapse, comment removal, boolean attribute collapsing, redundant attribute removal, removal of legacy script/style type attributes, HTML5 short doctype, and minification of inline CSS and JavaScript inside tags. Parse errors can be continued through during minification so you still get partial output — always verify in a browser. Load sample provides a small document; Clear resets everything; Download saves document.html.

Before you ship minified HTML

Aggressive minification can interact badly with fragile whitespace-dependent layouts or third-party snippets. Compare behavior in devtools and staging. This page reminds you to review output before production use.

Privacy

Prettier and html-minifier-terser run locally in your browser. Your markup is not uploaded to Dynamic Duniya servers.

Frequently Asked Questions

Does minify change how my page looks?

Usually not for normal documents, but whitespace between inline elements can affect rendering in edge cases. Test minified output in your target browsers. Beautify is the safe choice when you only need readability.

What does “continue on parse error” mean for minify?

The minifier is configured to try to keep going when the parser reports issues, which can help with messy pasted fragments but may produce unexpected results. Fix invalid HTML when possible.

Can Prettier beautify broken HTML?

Severely malformed markup may fail to parse; you will see an error instead of beautified output. Minify may still emit output when continue-on-parse-error is enabled — treat that as a best-effort preview, not a guarantee.

Can I download the result?

Yes. After Beautify or Minify succeeds, use Download .html to save document.html or Copy to grab the string.

Is this HTML tool free?

Yes. No account is required.

Tips

Quick guidance for using our tools safely and effectively.

Privacy

Files are processed on the server for conversion only and are not used for training or shared with third parties.

Best results

Use the formats suggested in each tool. Large media files may take longer — keep the tab open until processing finishes.

Need something else?

Browse related tools below or explore other categories from the main Dev Tools hub.

Related tools

More utilities in the same category.

Regex Tester

New

Test JavaScript-style regular expressions in your browser: enter a pattern, toggle global (g), case-insensitive (i), and multiline (m), paste sample text, and see highlighted matches with start indexes. Invalid patterns show a clear error. No signup; your strings stay on your device.

regexdeveloper+1

Base64 Encoder / Decoder

New

Encode plain UTF-8 text to Base64 or decode Base64 back to text in your browser (whitespace ignored when decoding). Swap encode/decode, copy the result, or upload a file in encode mode to extract the raw Base64 payload from a data URL. Convert runs client-side only.

encodingdeveloper+1

JSON Formatter & Validator

New

Pretty-print, minify, and validate JSON payloads.

jsonformatter+1

JSON Compare

New

Compare two JSON documents semantically — skip keys, optional array sorting, JSON paths, and side-by-side mismatch diffs. Runs entirely in your browser.

jsondiff+2

Text Diff Tool

New

Paste an original and a modified version, then Compare to see a unified diff: line-by-line with +/- prefixes and optional line counts, or word-by-word with highlights. Copy the plain-text diff, switch views anytime, or Clear. Uses the diff library in your browser — nothing is uploaded.

diffgit+1

SQL Formatter

New

Beautify SQL in your browser with the sql-formatter library: choose a dialect (PostgreSQL, MySQL, SQLite, BigQuery, and more), keyword case (upper, lower, preserve), and indentation (2 spaces, 4 spaces, or tab). Format, copy, or download query.sql. Identifiers and function names stay as typed unless you change keyword casing.

sqldatabase+1