SVG Optimizer
Paste the code of an SVG icon, logo or illustration and get a smaller file that draws the same picture. The optimizer removes comments, metadata and the extra data design tools add, drops empty groups, rounds the numbers in paths and coordinates to a precision you set, and shows how many bytes it saved.
What you enter
- SVG code
- Decimal precision
- Remove comments
- Remove metadata blocks
- Remove editor data, XML declaration and doctype
- Remove empty groups
- Remove title and description (hurts accessibility)
- Remove ids nothing refers to
What you get
- Original size
- Optimized size
- Bytes saved
- Saved
How it works
- Paste your SVG code into the box. Open the .svg file in a text editor and copy everything. It is processed in your browser and never uploaded.
- Set the decimal precision. Three is a safe default; lower numbers save more bytes but can shift curves slightly.
- Tick the clean-ups you want: remove comments, metadata, editor data from Inkscape, Illustrator or Sketch, empty groups, titles and descriptions, and unused ids.
- Read the sizes, then copy the result or download it as an .svg file.
Where the extra weight in an SVG comes from
An SVG file is text, and a freshly exported one is full of things a browser does not need. Editors save the program's own settings, window positions, layer names, grid guides and a metadata block describing the licence. A small icon can carry more bytes of leftovers than of drawing.
The other source is precision. Vector tools keep numbers with many decimals so edits stay exact, but a screen shows a few hundred pixels. Cutting the decimals, and dropping the zeros that a number does not need, is the single biggest saving on most illustrations, because path data is where the numbers are.
How path data is rewritten
A path is a string of commands and numbers, such as M10 20L30 40z. The optimizer reads it the way a browser does, one command and its numbers at a time, including the rule that a command can repeat with more numbers, and the compact arc form where the two flags are single digits that can run into the next number.
It then writes every number back at your precision with the fewest separators: no space is needed before a minus sign or before a second decimal point, as in .5.5. If a path cannot be read cleanly, it is copied unchanged rather than guessed at, so an unusual file loses a few bytes of savings and never its shape.
When to optimize, and when to stop
Optimize icons and logos that ship on every page of a site, because every visitor downloads them. Keep an unoptimized master in your design tool, and treat the optimized copy as a build output. Editing the optimized file by hand is possible but awkward, as the layer names are gone.
Past a point there is little left to save. A cleaned SVG is mostly its path data, and compression on the server shrinks repeated text further. If an image is a photograph traced into thousands of tiny shapes, a raster format such as WebP will usually be smaller than any vector version of it.
Tips
- Keep the title and description if the image carries meaning. Screen readers use them, so only remove them for decorative graphics that are hidden from assistive technology anyway.
- Leave unused ids alone when the SVG is placed inline in a page and your own CSS or JavaScript targets elements by id. Removing an id that outside code relies on breaks the style.
- Precision depends on the size of the drawing. In a 24 by 24 icon, one decimal place is a visible fraction of a pixel; in a 2000 by 2000 illustration, whole numbers are usually fine.
- Compare the result with the original at the size you will use it. If an edge or curve looks off, raise the precision by one and try again.
Frequently asked questions
What does an SVG optimizer remove?
Anything that does not change how the picture is drawn: comments, the XML declaration and doctype, metadata blocks, namespaced attributes added by editors such as Inkscape, Illustrator and Sketch, empty groups, unused namespace declarations and white space between tags. Optionally it removes title, description and unused ids.
How does rounding save space?
Design tools often write coordinates with six or more decimals, like 12.345678. Rounding to three decimals writes 12.346, and a trailing zero or leading zero is dropped, so 0.500 becomes .5. A path with hundreds of numbers shrinks noticeably, and the difference is far below what the eye can see at normal sizes.
Will the image look different?
At a sensible precision, no. Rounding to three decimals moves a point by less than a thousandth of a unit. Very small drawings with large scaling, or very low precision such as zero, can show shifted curves, which is why the precision is a setting you control.
What happens to text and styles?
Text, tspan, style and script contents keep their white space exactly, and CSS inside a style element is left unchanged. The tool only rewrites numbers in drawing attributes such as d, points, transform, viewBox, width, height and the coordinates of shapes.
Is my SVG uploaded?
No. The optimizer runs as code in your browser, so your artwork stays on your device.
Why does it say the SVG could not be read?
The code must be well formed XML: every tag closed, attribute values in quotes and one svg element at the top. A missing closing tag or an unquoted value stops the parser.
Related: SVG to PNG converter, Favicon generator, Image compressor.
Start for free or see all free tools. We.Inc is free to start, with no card needed. AI building is on paid plans from $20 a month.
More in Free Tools
- SVG Background Pattern Generator
- SVG to PNG Converter for Website Logos
- SVG Viewer and Editor
- SVG Wave and Shape Divider Generator
- Table of Contents Generator
- Tailwind Color Palette Generator
- Terms and Conditions Generator
- Text Diff Checker
Related guides
Product
Who It's For
- For Agencies
- For Freelancers
- For Hosting Providers
- For SaaS Platforms
- For Startups
- For Financial Services
- For Healthcare
Features
Resources
- Blog
- Help Center
- Free Business Tools
- Free UI Components
- Website Templates
- Template Collections
- Website Examples
- Guides
- Comparisons
- Alternatives
- Best Lists
- Reviews
- Pricing Guides
- Use Cases
- Glossary & Guides
- Integrations
- Developers
- Benchmark
- Windows App