Skip to content
Marvin's Toolbox.

SVG Optimizer

Shrink an SVG with SVGO. Paste the markup or drop a file, toggle every optimizer plugin individually, set the numeric precision and multipass, and compare the size before and after. Copy the result or download it as a file.

Runs entirely in your browser. Nothing you put in here gets uploaded.

Drop an .svg file here or click to browse. You can also paste the markup below.

Optimizer options

Rerun until nothing shrinks further
Indent instead of minifying
Precision3 decimals

Document cruft

Remove the DOCTYPE declaration.
Remove the <?xml ?> processing instruction.
Remove comments from the markup.
Remove <metadata> blocks.
Remove the <title> element. Screen readers announce it, so it stays by default.
Remove <desc> elements that only carry editor boilerplate.
Remove leftover namespaces from Inkscape, Illustrator, Sketch and friends.
Remove <script> elements and inline event handlers.

Styles and colors

Remove every <style> element outright.
Merge multiple <style> elements into one.
Move <style> rules onto the elements they match when possible.
Minify the CSS inside <style> elements.
Turn inline style declarations into presentation attributes.
Rewrite colors to their shortest form, like rgb() to hex.
Replace gradients with a single stop by that plain color.

Attributes and IDs

Remove attributes the SVG spec has deprecated.
Collapse newlines and repeated spaces inside attribute values.
Shorten IDs and drop unreferenced ones. Turn off when CSS or JS outside the file uses them.
Round numbers to the precision setting and drop default px units.
Round the numbers in list attributes like points and viewBox.
Remove unknown elements and attributes sitting at their default values.
Remove group attributes that cannot apply to children anyway.
Remove stroke and fill attributes that have no visible effect.
Remove or shorten enable-background where it does nothing.
Remove attributes with empty values.
Remove namespace declarations nothing uses.
Sort attributes into a consistent order that compresses better.

Shapes and paths

Convert basic shapes like <rect> and <line> into <path>.
Convert ellipses with equal radii into circles.
Rewrite path data with relative commands, shortcuts and rounding. Usually the biggest saving.
Merge transform chains into one shorter form.
Remove paths that lie entirely outside the viewBox.
Merge sibling paths that share the same styling.
Replace identical paths with <use> references to one definition.

Structure

Remove embedded JPEG and PNG <image> elements.
Remove <defs> content nothing references.
Remove elements that cannot be seen, like display:none or zero size.
Remove empty <text> elements.
Move attributes shared by every child onto their group.
Move a pointless group's attributes onto its children.
Dissolve groups that no longer serve a purpose.
Remove empty containers like <g> and <defs>.
Sort <defs> children into an order that compresses better.

Sizing and root

Remove the viewBox when it matches width and height. Breaks responsive scaling.
Remove width and height so the viewBox controls sizing. The opposite of removing the viewBox.
Remove the xmlns attribute. Only safe for SVG inlined into HTML.

Next steps

Send this tool's output straight into another tool.

Rasterize SVG files to PNG, WebP or JPEG at any size. Set an exact width and height or a scale such as 2x or 4x, keep transparency or fill a background colour, and download one file or the whole batch.

Compress images to JPEG at a target file size or quality, with presets for WhatsApp, Instagram and Discord, optional resizing and EXIF kept or stripped.

Convert images between JPEG, PNG, WebP and AVIF, and open iPhone HEIC photos too. Drop in as many as you like, pick a format, and dial in the quality for the lossy ones. When you convert to JPEG, choose the colour that fills any transparency. Live previews, download one or all at once.

See and edit the EXIF metadata inside a photo, then download it with your changes or save a copy with all metadata removed, GPS included. It reads JPEG, PNG, HEIC and more, and edits JPEG files.

Draw arrows, boxes, text, highlights and numbered steps on a screenshot, blur or pixelate anything private, crop the result and add a watermark. The finished image downloads as PNG or JPG or goes straight to your clipboard.

Shrink an SVG with SVGO. Paste the markup or drop a file, toggle every optimizer plugin individually, set the numeric precision and multipass, and compare the size before and after. Copy the result or download it as a file.

Hash text or a file with MD5, SHA-1, SHA-256, SHA-512, SHA-3, BLAKE2, BLAKE3, CRC32 and more, all computed live as you type. Compare against an expected checksum and copy any digest.

Verify a file against its checksum. Drop the file and paste the expected hash or a sha256sum line, and the hash type is detected for you, from MD5 to BLAKE3.

Compress text or a file with gzip, deflate, brotli or Zstandard and see the size before and after, the compression ratio and how long it took. One click tries every method and recommends the smallest result.

About the SVG Optimizer Tool

This tool runs your SVG through SVGO, the standard SVG optimizer, right on the page. Paste the markup or drop a file and the optimized result appears next to a before-and-after size comparison, usually a good deal smaller with no visible difference.

Every SVGO plugin is a switch you can flip. Start from the safe defaults, then enable the aggressive extras or disable anything that changes your file in a way you do not want. Numeric precision and multipass are exposed too.

What you can do

  • Minify an SVG exported from Figma, Illustrator or Inkscape.
  • Toggle each SVGO plugin individually to control exactly what is rewritten.
  • Reduce path precision to trade invisible detail for smaller files.
  • Compare the size before and after, with the saving as a percentage.
  • Preview the optimized SVG rendered next to the original.
  • Copy the optimized markup or download it as a file.

How to use the SVG Optimizer

  1. 1Paste SVG markup into the input, or drop an .svg file on it.
  2. 2Check the preview and the size numbers.
  3. 3Flip plugins on or off if the defaults removed something you need, like IDs you reference from CSS.
  4. 4Copy the result or download the optimized file.

When a plugin bites

A few plugins are worth knowing by name. removeViewBox deletes the viewBox attribute, which breaks responsive scaling, so it stays off here by default. cleanupIds renames or strips IDs, which matters when CSS or JavaScript outside the file references them. convertShapeToPath turns rectangles and circles into paths, which is fine for display but loses the semantic shape. If an optimized file misbehaves, turn plugins off in small groups to find the culprit.

What the numbers mean

The precision setting controls how many decimal places coordinates keep. SVGs exported from design tools often carry six or more decimals, far below what any screen can show. Three decimals is safe for icons, and one or two often still looks identical while cutting the file substantially. Multipass simply reruns the optimizer until the output stops shrinking.

Credits

Open source does the heavy lifting in this tool. Thank you to:

  • SVGO

    The standard optimizer for SVG files.

Everything this site builds on is listed on the credits page.

Tools that share a tag with this one.

Create barcodes in dozens of formats, from EAN-13, UPC-A and Code 128 to QR Code, Data Matrix and PDF417. Type the content, tune the size, colors and text options, and download the result as PNG or SVG.

Turn a code snippet into a clean image for docs, slides and posts. Pick a language, syntax theme, font size and window style, set the background and padding, then download a sharp PNG or copy it to the clipboard.

Turn any image into a complete favicon set: a multi-size favicon.ico, PNG icons in every common size, Apple touch and Android icons, a web manifest and the HTML tags to paste into your page. Download everything as a zip.

Compare two images and see exactly what changed. Slide between them horizontally or vertically, blink or blend them over each other, view them side by side, and let the pixel diff highlight every changed region with a difference percentage.

Compress images to JPEG at a target file size or quality, with presets for WhatsApp, Instagram and Discord, optional resizing and EXIF kept or stripped.

Enter a resolution to get its simplified aspect ratio, or start from a ratio and one side to get the missing dimension. Knows the common ratios like 16:9, 4:3 and 21:9 and shows how close your size is to each.