Crop an SVG to its drawing
Choose an SVG and the empty space round the drawing is trimmed away. The frame is set to the box that holds everything drawn, strokes included, with a margin if you want one.
Free, no account. The file is read by code running in your browser. It is not uploaded, and nothing about it is stored.
How to crop an SVG
- Choose your SVG, drop it on the box, or paste SVG code.
- The drawing is measured and the cropped picture appears beside the original.
- Add a margin if you want space left round the drawing: type it in the drawing’s own units, or press 2%, 5% or 10% of its longer side.
- Download the SVG.
What cropping an SVG means
A photo is cropped by throwing pixels away. An SVG has no pixels: it has shapes, and a viewBox that says which rectangle of the shapes’ coordinates to show. Cropping an SVG means changing that rectangle. This tool sets it to the smallest box that holds everything the file draws, and changes nothing else about the shapes.
The sample on this page is a star in a ring adrift on a 400 × 300 page. The drawing is 110 × 110 units and starts at 175, 65, so the cropped file gets viewBox="175 65 110 110". Its width and height were 400 and 300 pixels; they become 110 and 110, in the same unit the file used, so the drawing itself stays exactly the size it was and only the empty page is gone.
It works the other way too. If part of a drawing lies outside its frame and is cut off, the new frame is larger than the old one and takes it all in.
How the drawing is measured
Your browser draws the file, and the tool looks at the result. So the box is the box of what is actually visible: the full width of every stroke, not just the centre line that the path data describes; only the part of a shape that shows through a clip path or mask; the shadow a filter throws; the arrowheads on a line. A shape that is hidden or fully see-through takes up no room.
The picture is examined at 1,600 pixels along the drawing’s longer side, so the box is right to about one part in 1,600, and it is rounded outwards, never inwards. Plain shapes that are not rotated are also measured directly from their geometry, and where the two agree the exact figure is used: a 100 unit square with a 4 unit stroke gives a box of exactly 104.
What to know before you crop
- Nothing is deleted. Every shape stays in the file, and so does anything that was outside the old frame.
- A background counts. A rectangle behind the drawing, even a white one, is part of the drawing, so a file with one has nothing to trim. Remove the rectangle in an editor first.
- Text is measured as your device draws it. If the font named in the file is not installed, the browser uses another, and the box fits that one. Convert text to outlines in your editor for a box that holds everywhere.
- Percentages are rewritten. A shape placed at
x="50%"is placed relative to the frame, so it would move when the frame changes. Such values are replaced with the plain numbers they stood for, and the tool says so. - Only the outer element changes otherwise: its
viewBox, and itswidthandheightif it had them.
Questions
Why does my SVG have so much empty space round it?
It was probably exported with the whole page or artboard as its frame, and the drawing is smaller than the page. Cropping to the drawing fixes it. Many editors also have an export setting for this, such as “resize page to content”.
Does cropping remove the parts I cannot see?
No. Cropping only moves the frame. Shapes outside it are still in the file; they are just not shown. The file is the same size in bytes, give or take a few characters.
Can I crop to one part of the drawing?
Not with this tool: it crops to everything that is drawn. For a tighter crop, open the file in the SVG viewer and edit the four viewBox numbers by hand: left, top, width, height.
Will the drawing still be the right size for cutting or printing?
Yes. The width and height shrink by exactly as much as the frame does and keep their unit, so a shape that measured 50 mm still measures 50 mm. The new width and height are the true outer size of the drawing, strokes included.
Why add a margin?
A drawing cropped to nothing touches the edge of its frame on every side, which can look cramped on a page and leaves no room for error when it is placed. A margin of 2% to 5% is usually enough.