HTML minifier

Paste HTML to strip the indentation, line breaks and comments. A space between words or inline tags is kept as one space, because removing it would glue words together on the page. <pre>, <textarea>, scripts, styles and conditional comments are left untouched.

Open a file: (or drop it on this box)

Why formatting HTML can change the page

In HTML, a line break between two tags is not free: between inline elements it renders as a space. A formatter that puts every tag on its own line turns <b>€5</b>for into €5 for, and a minifier that strips all whitespace turns Contact Us</a> <a>Terms into Contact UsTerms. This tool follows the browser's whitespace rules instead:

When your CSS makes block tags inline: Strict mode

The rules above assume each tag's default display. Real sites often restyle them: a navigation <ul> with li { display: inline }, or an inline-block grid. Then a line break between two <li> tags shows up as a gap. We measured this on 29 real home pages (Wikipedia, BBC, MDN, GOV.UK, Stripe, framework sites and more), rendering each before and after in Chromium with JavaScript off and comparing the visible text: Wikipedia and BBC News changed with this tool's default mode, and just as much with js-beautify (the engine behind most online beautifiers) and Prettier (which also refused 3 of the 29 pages over syntax errors). Stripping every space next to block tags changed Wikipedia and NPR's text-only site.

So the page runs that check for you: after formatting, it renders the input and the output in two sandboxed frames (inline CSS applied, no scripts, nothing fetched) and compares the text a reader would see. If it differs, switch Whitespace to Strict: line breaks then go only where there was already whitespace, which keeps the rendering identical under any CSS (all 29 pages unchanged, formatted and minified). The minifier uses Strict by default: it keeps one space where whitespace touched a block tag, which cost 0.29% of the size on those 29 pages. Try the Inline-list example button to see both modes.

Markup issues it reports

Browsers never reject HTML; they repair it silently, which is how a missing </div> ends up swallowing the footer. The formatter builds the same tree the browser does (implied </p>, </li> and </td> are fine and not reported) and lists what it had to repair, with line numbers:

Turn the HTML into a PDF or an image

Formatting an invoice, a report or an email template? The Shotmint API renders HTML in real Chromium: POST https://shotmint.creasework.com/v1/pdf with {"html": "…"} returns a PDF, and /v1/screenshot returns a PNG (1 credit each; 25 free renders a month, then €5 for 2,000 that never expire). Scripts, AI agents and Make or Zapier can get a key with a bare POST https://shotmint.creasework.com/v1/keys/free (no body, JSON reply); the request bodies are described in openapi.json. To check a page live while you edit it, use the HTML editor.

Get 25 free renders a month API docs

FAQ

Is my HTML uploaded? No. Formatting and the rendered check run in your browser. The check frames block scripts and every network request, so nothing in your HTML is fetched or executed.

Does it format the CSS and JavaScript inside the page? No. Code in <style> and <script> is kept as written, so a minified bundle stays minified and nothing in it can break.

Does the minifier remove optional tags or attribute quotes? No. It removes indentation, line breaks and comments only. Dropping quotes and optional tags saves a few more bytes but makes the markup fragile to edit, and gzip already compresses most of that away.

Related tools: HTML formatter, HTML beautifier, HTML viewer, HTML editor, HTML to Markdown, XML formatter, JSON formatter.

Related tools

PDF to HTML · HTML to image · HTML to PDF · HTML formatter · Word to HTML · HTML to Markdown · HTML to Word · Markdown to HTML · Online HTML editor · HTML viewer · HTML Encode · HTML to DOCX · HTML Decode · HTML to JPG Converter · HTML Beautifier · HTML to PNG Converter · DOCX to HTML · all free tools