SVG Minifier

Collapse whitespace in SVG markup to a single compact line — a fast, text-based pass that leaves every element, attribute, and value untouched. Runs entirely in your browser.

Original: 284 BMinified: 207 B27% smaller

Why minify SVG markup?

Design tools and code formatters often output SVG with generous indentation and line breaks for readability. None of that whitespace affects how the SVG renders, but it does add bytes — which matters when the SVG is inlined directly in HTML, embedded as a data URI, or served thousands of times a day. Collapsing it to a single line can shave 10–30% off the file size with zero visual change.

Text-based vs. DOM-based minification

Most SVG optimizers parse your markup into a DOM tree and re-serialize it — which can reorder attributes, normalize quote styles, or rewrite self-closing tags as a side effect. This tool works directly on the text, so the only thing that changes is whitespace. That makes it a safe first pass before further processing, and a reliable choice when you need the output to match your input as closely as possible.

Frequently Asked Questions

How is this different from the SVG Optimizer's minified mode?+

The Optimizer parses your SVG into a DOM, removes redundant nodes and attributes, then re-serializes it — a process that can subtly reorder attributes, change quote styles, or rewrite self-closing tags. This minifier is purely text-based: it never reparses your markup, so the output is byte-identical to your input except for whitespace. It also keeps working on SVGs with minor markup quirks that would trip up a strict XML parser.

What exactly does minifying remove?+

Only whitespace: line breaks and indentation between tags, and runs of multiple spaces or tabs anywhere in the markup are collapsed to a single space. No elements, attributes, comments, or metadata are touched — if you want those removed too, use the SVG Optimizer or SVG Metadata Remover.

Will minifying change how my SVG renders?+

No. Whitespace between tags has no visual effect in SVG (outside of <text> elements with significant whitespace, which this tool does not collapse). The minified output renders identically to the original — only the file size changes.

Is my SVG sent to a server?+

No. Minification is a simple string transformation that runs entirely in your browser. Your SVG markup never leaves your device.

How to use

  • Paste formatted or indented SVG markup — the minified output appears instantly.
  • Only whitespace between and around tags is collapsed; nothing else changes.
  • Copy the result with the Copy button — it renders identically to your original.