What cropping an SVG actually changes
An SVG has two ideas of size. The viewBox is the rectangle in the file's own coordinates that is mapped onto the page. The width and height attributes are how large that rectangle is drawn. Extra whitespace almost always means the viewBox is larger than the ink: the file was exported with a whole artboard, shapes were moved or deleted, or an icon sits on a padded grid.
This cropper changes the viewBox (and sets matching width and height). It does not scale, move or delete elements. If the file had a preserveAspectRatio attribute, that is removed so the new box is used as-is.
A worked example, with the numbers
Take a 100 × 100 canvas with a circle of radius 20 at the centre. The ink only occupies the middle 40 units, so you see a lot of empty margin:
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100"> <circle cx="50" cy="50" r="20" fill="#3b5bdb"/> </svg>
The content box is x = 50 − 20 = 30, y = 30, width = 40, height = 40. After a crop with padding at 0, the file becomes:
<svg xmlns="http://www.w3.org/2000/svg" viewBox="30 30 40 40" width="40" height="40"> <circle cx="50" cy="50" r="20" fill="#3b5bdb"/> </svg>
The circle element is unchanged — its centre is still (50, 50) in the original coordinates. The new viewBox starts at (30, 30), so the circle now fills the frame. With padding set to 4, the tool subtracts 4 from x and y and adds 8 to each side, giving viewBox="26 26 48 48" and a 48 × 48 width and height. That padding is useful when the shape has a stroke (see below).
How to use the cropper
- Drop an SVG file onto the tool, or paste the markup. The file is not uploaded; measurement happens in your browser.
- Two previews appear: Original on the left, Cropped in the middle. The cropped caption also shows the new size, rounded to whole units, for example
40 × 40. - Use the Padding slider (0 to 64) if you want a margin around the ink, or if a stroke is being clipped.
- Download the result (the filename gets a
-croppedsuffix), copy the markup, or open it in the editor for a manual tweak. Reset starts over with a new file.
Strokes, hidden leftovers and empty files
The browser's getBBox() reports the geometry of the paths and shapes, not the thickness of a stroke. A circle with r="20" and stroke-width="8" still measures 40 units across, but the paint extends 4 units past that box. At padding 0 the stroke is clipped on all four sides. Move padding to at least half the stroke width to keep the outline.
Shapes with no visible paint, or a file whose content measures zero width or height, produce the error “No visible content to crop to.” That can happen with an empty artboard, or with artwork that only exists as a stroke so thin or so far out of view that the box collapses. Open the file in the SVG viewer if you need to inspect the markup first.
Because crop does not delete elements, a stray path parked far off the artboard still lives in the file after a tight crop. It will not show, but it can confuse the next edit and add bytes. If the file used to have a huge canvas, check the editor layers after cropping and delete anything you did not mean to keep.
When not to crop, and what to do instead
Leave the padding alone on icons that belong to a set. Designers put a 24 × 24 (or 16 × 16) grid around each glyph on purpose, so a “play” triangle and a “pause” pair of bars line up optically. Cropping each one to its ink makes the triangle look larger than the bars. Crop the finished logo or illustration, not the individual set glyphs.
Cropping is also the wrong tool when you want a different display size but the same canvas. That is Resize SVG, which changes width and height (or strips them for a responsive file) and leaves the viewBox alone. If you need a custom window that is not the content bounds — for example a square frame around a wide wordmark — set the artboard in the editor and position the artwork yourself.
Once the frame is tight, the SVG to PNG converter will export a bitmap without a ring of empty pixels, which is what you want for a sticker or a tightly cropped logo. For print at a chosen DPI, follow that with how to convert SVG to PNG for print.