PrettifyPrettify

SVG Optimizer Online

Design tools save much more in an SVG than the drawing needs: editor metadata, comments, long decimals, and sometimes scripts. The Prettify SVG optimizer removes that with svgo, shows how many bytes it saved, and compares the pixels so you know the icon still looks the same. Your file never leaves your browser.

Result
The source, viewBox, size, and ids show here as you paste. Open the Image view to see it drawn.
Runs in your browser. Nothing is uploaded.

What the SVG optimizer does

An SVG minifier makes the file smaller without changing what it draws. The Optimize step in Prettify SVG Tools runs svgo on your SVG. It removes editor data, comments, and extra digits, and it shortens path data. It also removes script elements, on* event attributes, and javascript: links, which svgo keeps by default.

The box on this page checks your SVG and shows its viewBox, size, and number of ids. Optimize itself runs in SVG Tools in the editor. Select "Open in Image view", then select Tools in the toolbar.

Key features

Optimize is the first of the three SVG Tools steps. The other two, Unique IDs and React component, are optional for a smaller file.

  • The step shows the size before and after, for example 1.2 KB → 339 B, and the percent saved.
  • An Original and Result switch in the toolbar draws each version, so you can compare them by eye.
  • Next to the switch, a status says "Same drawing" or "Changed". Prettify draws both versions at the same size and compares the pixels.
  • When the SVG has scripts, the panel says so before you apply the result.
  • Optimize keeps an id when aria-labelledby, aria-describedby, or a SMIL timing value refers to it, and it keeps role="img".
  • The SVG tab shows the result with indents. Copy SVG copies it without the added indents.
  • The document does not change until you select Apply to document.

How to optimize an SVG

The box reads SVG up to 512 KB. For an SVG over 512 KB, SVG Tools runs the steps only when you select Run.

  1. Paste your SVG into the box labeled "Paste your SVG", or select "Try an example".
  2. If the box shows an error, fix the line it names first. Optimize needs an SVG that parses.
  3. Select "Open in Image view", then select Tools in the toolbar.
  4. Leave Optimize on. If you only want a smaller file, turn off Unique IDs, because its prefixes make each id longer.
  5. Read the size line and the Same drawing status.
  6. Select Copy SVG, or select Apply to document and then Download to save the .svg file.

Worked example: an Inkscape export

The example in the box is a bell icon saved from Inkscape. It has an XML declaration, an Inkscape comment, Inkscape and Sodipodi namespaces, a namedview element, an empty defs element, path data with six decimal places, and a script element.

The panel warns "This SVG has scripts. Optimize removes them." The Optimize step then shows 1.2 KB → 339 B, 72% smaller, and the status says Same drawing. The result is below. The ids and the style attributes stay, and the path is rewritten with short commands. With Unique IDs on, every id gets the prefix icon_ and the file is 359 B.

<svg xmlns="http://www.w3.org/2000/svg" id="svg5" width="32" height="32" viewBox="0 0 32 32">
  <g id="layer1">
    <path id="path1" d="M16 4a8 8 0 0 0-8 8v7l-3 4h22l-3-4v-7a8 8 0 0 0-8-8" style="fill:#f59e0b;fill-opacity:1;stroke:none;stroke-width:1"/>
    <circle id="circle1" cx="16" cy="26.5" r="2.5" style="fill:#f59e0b;fill-opacity:1"/>
  </g>
</svg>

Common uses

A smaller SVG loads faster and reads better in a code review. Most savings come from files that a design tool saved.

  • Shrink icons and logos from Inkscape, Illustrator, or Figma before you add them to a site.
  • Remove scripts and event attributes from an SVG that you did not make.
  • Clean up an SVG before you inline it in HTML, so the markup is short enough to read.
  • Check that an optimized icon still draws the same before you commit it.
  • Prepare an icon for the React component step, which works on the optimized markup.

Free and Pro

Optimize is part of SVG Tools, a Pro feature. Without Pro, the panel still estimates the saving, for example "This SVG can be 72% smaller with SVG Tools." Pro costs US$19.99 once, with lifetime access and no subscription.

The SVG viewer is free: the Image view with zoom, backgrounds, and icon sizes, plus the Raw view and Download. Optimize runs in your browser, and Prettify does not upload your SVG.

Frequently asked questions

Is the SVG optimizer free?

Optimize is part of SVG Tools, which is Pro. Pro costs US$19.99 once. Viewing the SVG, the size estimate, and Download are free and need no account.

Will optimizing change how my SVG looks?

It should not, and Prettify checks. The status next to the Original and Result switch compares the pixels of both versions at the same size and says "Same drawing" or "Changed". A small difference in color or edge does not count.

What does the optimizer remove?

Editor data, comments, and extra digits, through the svgo default set of steps. It also removes script elements, on* event attributes, and javascript: links. It keeps ids that aria attributes or SMIL timing refer to, and it keeps role="img".

Why is the result bigger than the Optimize step says?

The Optimize step measures Optimize alone. Unique IDs then adds a prefix to every id, which makes the file a little bigger. With Result selected, the badge in the toolbar shows the final size. Turn off Unique IDs if you do not put several SVGs on one page.

Can I undo the optimization?

Yes. Apply to document adds one version to History, and a notice with an Undo button shows for a few seconds.

Related tools