SVG Minifier
FormatEverything runs locally in your browser — nothing is uploaded
Shrink the SVG a design tool exported: drop comments and `<title>`/`<desc>`/`<metadata>`, collapse whitespace and newlines between tags, cut coordinate precision and remove unreferenced `id`s. Coordinates are where the bytes are: path data (`d`) is usually more than half the file, and it is one long list of numbers. Taking `M12.345678` down to `M12.35` typically saves twenty to thirty percent and is invisible — hence the 3-decimal default. ⚠️ A generic “strip all whitespace, delete every unused attribute” pass silently corrupts SVG, and corruption usually shows up as “a piece is missing” with no clear warning. So each rule here states what it will not touch: `viewBox` is never modified (remove it and the SVG can no longer scale, while it still looks right at one fixed size), spaces inside `<text>` are content (`Hello World` collapsing to `HelloWorld` is the classic accident), and a referenced `id` must never be dropped (`url(#a)` points at it, and the gradient disappears).
Features
- Removes comments and title / desc / metadata (whole blocks, nesting included)
- Collapses whitespace between tags while leaving `<text>` / `<tspan>` / `<style>` / `<script>` untouched
- Coordinate precision 0–3 decimals for path, points, transform and similar attributes; 3 by default
- Removes only unreferenced ids (`url(#a)`, `href="#a"` and SMIL `begin="a.click"` all count as references)
- Never touches viewBox or preserveAspectRatio
- Leaves colours, class names and style attributes alone (`#ff0000` never becomes `#ff0`)
- Optional xmlns removal, labelled as applying only when inlining into HTML
- Syntax-highlighted output with the resulting character count below it
How to use
- Paste your SVG source
- Toggle as needed — by default it does only the four safe things: comments, metadata, whitespace, 3 decimals
- For more, drop to 1–2 decimals or enable unreferenced-id removal
- Copy the minified result
FAQ
- Why can viewBox not be removed?
- Because `viewBox` defines the coordinate system: which part of the drawing maps onto which area. Remove it and `preserveAspectRatio` stops working too, so the SVG loses its ability to scale — while still looking correct at the one fixed size you set. The problem only appears when someone else drops it somewhere else (a distorted icon, or one corner showing). The dozen characters saved are not worth that risk, so this tool does not touch it at all.
- Why is whitespace inside text left alone?
- Because it is content. Removing the space in `<text>Hello World</text>` turns it into one word, and on screen that reads as “the text is cramped” — easily mistaken for a font problem. So collapsing happens only between tags; inside `<text>`, `<tspan>`, `<style>` and `<script>` everything is preserved verbatim. The last two are not markup languages at all, and have their own whitespace rules.
- Does reducing precision distort the shape?
- At 3 decimals, not visibly (on a 24px icon, 0.001 is about a fortieth of a screen pixel). At 1 decimal (0.1) you start to see slight polygonal faceting when the SVG is rendered large, especially on curves and diagonals; at 0 decimals (integers) small icons are fine, but magnification shows obvious error. Hence the 3-decimal default — judge the aggressive settings by asking whether this SVG will ever be displayed at a very large size.
- Should xmlns be removed?
- It depends how you will use the file. Inlined into HTML (the `<svg>` written directly into the page) it can go — a few bytes, and the parent document’s namespace takes over. But as a standalone `.svg` file, in a CSS `url()`, or as an `<img src>` target it must stay: without it the browser does not recognise the file, and the symptom is “nothing displays” while the file itself looks perfectly fine. That is why this option is off by default, with the condition stated on the label.
Related tools
XML Formatter
FormatFormat XML online by tag level, with comments, CDATA and DOCTYPE on their own lines and attribute values left untouched. Runs locally in your browser.
Image Converter
ImagesConvert between PNG, JPEG, WebP, AVIF, BMP and TIFF, with adjustable quality and size. JPEG output lays a background, so transparency never turns black.
Image Compressor
ImagesCompress an image to a target size (say under 200 KB): the tool binary-searches for the highest quality that fits. Quality steps and size limits too.
JSON Formatter
FormatFormat, validate and minify JSON in a collapsible tree with syntax highlighting and line numbers. Search, edit, delete or convert to Python dicts.
JSON to Code
FormatTurn JSON into TypeScript interfaces, Go structs, Java classes or Rust structs, with missing keys marked optional. Runs locally in your browser.
SQL Formatter
FormatFormat SQL online: one clause per line, consistent keyword case, subqueries indented deeper. Minify strips comments and extra whitespace, all locally.