Saved

Press the star next to a tool's name to save it.

All my tools

SVG Optimizer

Paste SVG markup into this SVG optimizer and it removes metadata, comments and redundant data with SVGO. You see the size before and after, a live preview of the result, and can copy or download the file.

Fewer decimal places make smaller files but can shift fine detail. Removing width and height lets the image scale to its container; it needs a viewBox.

Your code stays in your browser. Nothing is uploaded.

Result

Paste SVG code and press Optimize.

SVG files exported from design tools carry a lot of baggage: editor metadata, comments, empty groups, long decimal numbers and default settings written out in full. An SVG optimizer strips that away. This SVG optimizer runs SVGO on the code you paste, shows how many bytes you saved, previews the result and lets you copy or download the optimised file.

What the SVG optimizer does

SVGO is a Node.js library and command-line tool for optimising SVG files. It removes redundant content such as editor metadata, comments, hidden elements and default or suboptimal values without changing how the image renders. [1] This page runs the library in your browser with its standard set of plugins, called the default preset. Typical changes are shorter path data, merged shapes, removed empty containers and numbers rounded to a chosen precision.

Options explained

  • Decimal places: how many digits are kept in coordinates. Three is the default and a good balance. One or two make smaller files for simple icons. Four or five keep more accuracy for detailed drawings.
  • Passes: Repeat until smallest runs the plugins again until nothing shrinks further, which can squeeze a few more bytes. One pass is faster on huge files.
  • Width and height: keep them, or remove them so the image scales with its container.

Width, height and viewBox

The viewBox attribute sets the position and size of the drawing area in user units, and the image is stretched or resized to fit the container when a viewBox is present. [2] Width and height set the size at which it is displayed. If you remove them, the SVG follows its container and the viewBox keeps the proportions. Use that option only when the SVG has a viewBox; otherwise keep them.

Preview and download

After you press Optimize the result box shows the new code, a preview image drawn from it and a line like 1,240 bytes down to 410 bytes, 67% smaller. Compare the preview with your original before you use the file. Download gives you optimized.svg and Copy puts the code on your clipboard for pasting into HTML or a component.

Worked example

Paste an SVG that has an XML declaration, a comment, a metadata block and a group around a rectangle with width 5.123456. With the default settings the result is a short svg element containing one path, with the rectangle written as a path with width 5.123. Drop the decimal places to 1 and it becomes 5.1. The file is a fraction of the original size and looks the same.

When to optimise SVG

  • Icons and logos inlined in HTML, where every byte adds to the page.
  • Illustrations exported from Figma, Illustrator or Inkscape that carry editor data.
  • Files for email or documentation sites with size limits.
  • Before adding a graphic to a sprite or a component library.

Why SVG files grow

Design programs write SVG for editing, not for the web. They store layer names, guides, generator comments, unused definitions and coordinates with many decimal places, because that information helps while you work on the drawing. None of it is needed to show the picture. Optimising removes that extra data and rewrites paths into their shortest equivalent form, so icons and illustrations load faster and take less space when inlined in a page. For a set of icons used across a site the saving adds up quickly, and smaller files are easier to read and diff when they are stored in a repository.

It is good practice to keep the original editable file and publish the optimised copy.

Common mistakes

  • Setting too few decimal places on detailed artwork, which shifts curves. Check the preview.
  • Removing width and height from an SVG with no viewBox, leaving it with no natural size.
  • Pasting only part of an SVG. The code must start with an svg element.
  • Expecting the tool to convert raster images. For photos use a tracer or keep the original format.

Security note

SVG is text that can contain scripts and links. This tool does not execute your SVG in the page: the preview is shown through an image element, which does not run scripts. Even so, only embed SVG from sources you trust, and inspect files before you inline them into a site.

How much you can save

Files exported from editors often shrink by half or more. Hand-written or already optimised SVG shrinks little, and the tool tells you when the file was already compact. Servers also compress SVG with gzip or Brotli, so the real saving over the network is smaller than the raw figure, but optimised files still load and parse faster.

Privacy

Optimising happens entirely in your browser. Your drawing is not uploaded, which matters for unreleased logos and client artwork.

To turn an SVG into a PNG use the SVG to PNG converter. To trace a bitmap into SVG, the JPG to SVG and PNG to SVG converters can help. Use the CSS and JavaScript minifier for the stylesheets and scripts around your graphics.

What next

Use this often? Add SVG Optimize to your Home screen.

Frequently asked questions

What does an SVG optimizer do?

It rewrites SVG code to be smaller without changing how the picture looks. It removes editor metadata, comments, hidden elements and default values, and shortens path data and numbers.

Which tool does this SVG optimizer use?

It runs SVGO, the Node.js library for optimising SVG files, in your browser with its default preset of plugins.

Will optimising change how my SVG looks?

Normally not. Lowering the decimal places can move points by a tiny amount, so check the preview. If a detail shifts, raise the decimal places to 4 or 5.

Why remove width and height?

Without them the SVG scales to fit its container, using its viewBox for proportions. That is useful for responsive layouts, but an SVG with no viewBox can lose its size, so keep the attributes if there is no viewBox.

Is my SVG uploaded?

No. Optimising happens in your browser, and the download is made from the text on this page.

What went wrong?

We only receive the reason you pick, never what you typed into the tool.

Thanks for your feedback.

More Developer Tools