Skip to content

SVG Optimizer & JSX Converter

Clean and minify SVG code, then copy it as markup, a data URI or JSX.

SVG optimizer

Waiting for SVG
Original
—
Optimized
—
Saved
—
Pixel match
—

Visual diff

ORIGINAL
OPTIMIZED

Field guide for designers & developers

Clean SVG: smaller files, sharper icons, fewer surprises

An icon that renders in 300 bytes often ships at 6 KB, because the file still carries the design app’s private notes, coordinates to eight decimal places and layers nobody can see.

01Where SVG bloat comes from

SVG is XML, so design tools can store anything in it. Typical exports carry:

  • Editor state: Inkscape’s sodipodi:namedview with zoom level and window position, Illustrator’s private data, layer names in inkscape:label or data-name.
  • Document metadata: RDF and Dublin Core blocks, generator comments, XML declarations and doctypes.
  • Over-precise numbers: 12.345678901 where 12.35 lands on the same pixel.
  • Verbose styling: style="fill:#d97706;fill-opacity:1;stroke:none;stroke-width:0.26458" where fill="#d97706" renders identically.
  • Structural leftovers: empty groups, single-child wrappers, unused gradients and clip paths from deleted layers.

None of it changes what the browser draws, but all of it is downloaded, parsed and, for inline SVG, kept in the DOM of every page.

02Precision without drift

Lowering precision is where most savings come from, and where naive minifiers break shapes. Path commands are often relative: each point is stored as an offset from the previous one. Round every offset independently and the errors add up, so a long outline slowly walks away from where it should end.

This tool converts every point to absolute coordinates first, rounds those, and only then works out the shortest way to write each segment, absolute or relative. Each point is within half a step of its true position no matter how long the path is. Choose precision from the size of the drawing:

ArtworkTypical viewBoxPrecision
UI icons0 0 24 242
Logos, illustrations0 0 200–8001–2
Maps, charts, large artwork0 0 1000+1
Tiny icons drawn on a 1-unit grid0 0 1 14–5
The pixel match readout renders both versions and compares every pixel. If it drops below 99.9%, switch to the Difference view to see exactly which edges moved, then raise precision by one step.

03Reading path data

A path’s d attribute is a list of drawing commands. Uppercase letters use absolute coordinates; lowercase use offsets from the current point:

M 10 10      move to (10, 10)
h 30         line 30 to the right
v 20         line 20 down
L 10 30      line to (10, 30)
c 0 -5 ...   cubic curve, control points relative
z            close the shape

The optimizer picks absolute or relative per segment, whichever is shorter, uses H and V for straight horizontal and vertical lines, turns curves whose first control point mirrors the previous one into the S and T shorthands, drops repeated command letters, and removes every separator the grammar does not need: M10 10L20 20 becomes M10 10 20 20, and 0.5 -0.5 becomes .5-.5.

04Inline SVG, a file or a data URI

MethodBest forTrade-off
Inline <svg>Icons styled with CSS, animated or interactive graphicsNot cached separately; repeats in every page’s HTML
.svg fileLogos and illustrations reused across pagesOne request; cannot be recolored with CSS
Data URISmall CSS backgrounds, patterns, list markersInflates the stylesheet; best under about 4 KB

For SVG, URL-encoding beats base64: base64 adds a third to the size and compresses poorly, while URL-encoded SVG only escapes a handful of characters and stays readable. The tool swaps double quotes for single quotes so the result drops straight into url("…").

05SVG in React

JSX is not HTML: hyphenated attributes become camelCase, class becomes className, and inline styles must be objects. The generated component handles all of that and spreads props onto the root element:

import ArtisaneaMark from './ArtisaneaMark';

<ArtisaneaMark className="h-6 w-6 text-amber-700" aria-hidden="true" />

Turn on Use currentColor for single-color icons and they inherit the surrounding text color, so one component serves every theme, hover state and dark mode. Turn on 1em size and the icon scales with the font size of its parent.

06Export settings that help before you optimize

  • Illustrator: File › Export › Export As › SVG, with Styling set to Presentation Attributes, Object IDs set to Minimal, and Responsive ticked.
  • Inkscape: Save As › Optimized SVG, or Plain SVG at minimum. Inkscape SVG keeps all editor data.
  • Figma: untick Include id attribute unless you need it, and outline text you do not want to depend on installed fonts.
  • Everywhere: convert text to outlines for logos, and remove hidden layers before exporting; hidden layers still ship in the file.

Questions

Frequently asked

01Will optimizing change how my SVG looks?

It should not, and the tool checks. Both versions are rendered to a canvas and compared pixel by pixel; the match percentage appears above the preview and the Difference view highlights any changed pixels. If precision rounding moves an edge visibly, raise the decimal places by one. Most icons on a 24-unit grid are pixel-identical at 2 decimals, and large illustrations at 1.

02What does "editor metadata" include?

Data that design apps store for themselves and browsers ignore: Inkscape and Sodipodi attributes and named views, Illustrator and Adobe extensibility namespaces and private data, Sketch, Figma, Serif and Boxy SVG attributes, RDF and Dublin Core metadata blocks, XML declarations, doctypes and "Created with" descriptions. Removing them never changes the rendering and often removes half the file.

03Should I use a data URI, an inline SVG or a file?

Use an inline SVG or a React component for icons you want to recolor with CSS through currentColor. Use a data URI for small background images in CSS, such as patterns or decorative shapes under about 4 KB, which saves a request. Use a separate .svg file for anything large or reused across many pages, so the browser can cache it. The URL-encoded data URI is smaller than base64 for SVG and stays readable.

04How is the React component different from the SVG?

Attributes are converted to JSX names, such as stroke-width to strokeWidth, class to className and xlink:href to xlinkHref, inline styles become style objects, and the props are spread onto the root svg so you can pass className, width, aria-label or onClick. With the TypeScript option the component is typed as SVGProps<SVGSVGElement>. With currentColor enabled, a single-color icon inherits the text color of its parent.

05Is it safe to paste SVG files from unknown sources?

The previews render SVG through image elements, where scripts never run, and by default the optimizer removes script elements, event handler attributes and javascript: links from the output. SVG is still code: if you inline SVG from an untrusted source on a website, keep the script removal option on and review any foreignObject content.

Keyboard shortcuts

Open file / load sampleO S
Paste SVG anywhere on the pageCtrl V
Precision down / up[ ]
Output: SVG, data URI, JSX1 2 3
Copy / download outputC D
Diff view: split, slider, differenceV
Preview backgroundB
ClearX
This panel?