My tools

HTML FORMATTER / PRETTIER · MINIFY

HTML Formatter

Paste or drop HTML to get consistent indentation from Prettier, embedded CSS and JS included; switch to minify to remove comments and extra whitespace, then copy or download.

Runs locally · code is not uploaded
Options

YOUR NEXT STEP

Connect useful tools with your company workflow

Create a company account to configure website monitoring, business email and notifications, and invite your team to work together.

New companies receive a 7-day Pro trial, with no card required. Trials exclude the paid monthly credit grant.

Already have an account? Open your workspace →

How to use it

  1. Paste code, drop a file or load the sample; the language is preset for this page and can be changed.
  2. Choose format or minify and adjust indent, width and other options; the result appears on the right as you type.
  3. Copy or download the result; on an error, use "Go to error", fix it and run again.

Code style options

Common conventions
OptionsRecommendation
Indent2 spaces (common in front end) / 4 spaces / tab
Line widthWrap at 80; 100 or 120 for wide screens
QuotesDouble (Prettier default) or single
SemicolonOn by default to avoid ASI surprises
Trailing commasAdded on multi-line lists for cleaner diffs

Languages and engines

Formatting uses the same open-source engines as popular editors, so results match Prettier in VS Code and your team can keep one style. Every engine loads from this site and runs in your browser.

Language
LanguageFormatCompress
HTMLPrettier 3✓ comments and whitespace
XMLXunL XML engine✓
CSS / SCSS / LessPrettier 3✓ CSSO restructuring
JavaScript / TypeScriptPrettier 3 (Babel)✓ Terser (JavaScript only)
JSONPrettier 3✓ big numbers keep precision
YAMLPrettier 3— (comments kept)
SQLsql-formatter (14 dialects)—

Frequently asked questions

Will formatting change how the page looks?

By default whitespace follows CSS display: block elements may break lines while spacing between inline elements such as span and b is preserved, so rendering stays the same. "Strict" is the most conservative; "Ignore" is the tidiest but can change inline spacing.

Is HTML minification safe?

It is conservative: ordinary comments are removed (IE conditional comments stay), runs of whitespace collapse to one space and are removed only between block tags; pre, textarea, script and style content is untouched.

Is my code uploaded?

No. The engines download from this site and run in your browser; your code never passes through our servers or any third party, so it is safe for internal code and configuration.

How large can files be?

Up to 5 MB per file; above 300 KB the page waits for the button instead of formatting as you type, to keep the browser responsive.

HTML formatter practical guide and common questions

What does HTML formatting change?

Prettier 3's HTML parser handles whitespace by CSS display: block elements may break lines while spaces between inline elements are kept; code inside style and script is formatted by the CSS and JS engines.

Who is this for, and when is it useful?

Developers, marketers and site builders working with page source, email templates and product description code, reading or editing it or minifying it before release.

How do I format HTML while preserving source semantics?

Paste or drop HTML to get consistent indentation from Prettier, embedded CSS and JS included; switch to minify to remove comments and extra whitespace, then copy or download.

What should I check after formatting HTML?

HTML minification is conservative and removes whitespace only between block tags, leaving pre/textarea, script and style content untouched; with template syntax such as {{ }} or <?php ?> mixed in, keep a backup and check the rendered page.

Where is the work performed, and which services receive data?

HTML is formatted in your browser; pasted scripts are never executed or uploaded.