Smaller, and still the same drawing

Every step is lossless except rounding, which is optional. Nothing reorders paths or merges shapes.

HomeProfessionsDesign › SVG optimiser

Smaller, and still the same drawing

Every step here is lossless except rounding, which is optional. Nothing reorders paths or merges shapes — a smaller file that renders differently is not an optimisation.

Local tool — nothing you make here is uploaded

Drop an SVG here, or click to choose.

It is read in this tab and never uploaded. Or paste the markup below.

Nothing here leaves this browser. Colours, images, SVG and generated code are processed on your own device. No file is uploaded, nothing you enter is stored on a server, and none of it is passed to the analytics or advertising scripts on this page.
What this refuses to do

Plenty of optimisers merge adjacent paths, convert shapes to paths, collapse groups and reorder elements. Each of those can change the drawing — a group carrying a transform or an opacity is not removable, and merging paths with different fill rules changes what is filled.

This does the safe things: collapse whitespace, remove editor metadata, drop attributes already at their default, remove genuinely empty groups, and optionally round coordinates. The saving is smaller and the output is the same picture.

It also sanitises. Scripts, event handlers and external references are removed on the way through, and what was removed is listed. A smaller file with a script in it is not a win.

Precision is where the size actually is

Editors export coordinates at full double precision — 24.000000000000004 — and a path with two hundred of those is mostly zeros. Rounding to three decimal places is invisible at any realistic size and often halves the file.

Below two decimal places curves start to flatten visibly on a large canvas. Check the result at the size you will actually use, not at thumbnail size.

An SVG is a document

It can contain scripts, event handlers, external references and embedded HTML. An SVG from a stock site or a client is untrusted input, and inlining it into a page without sanitising is a cross-site-scripting hole.

This works from an allowlist: a known set of elements and attributes is kept and everything else goes, which occasionally removes something harmless and never leaves something harmful.