Trim SVG whitespace

Auto Crop SVG

Upload an SVG and automatically tighten the viewBox around the visible artwork so extra empty space is removed.

Runs Locally

This tool runs in your browser. Files never leave your device.

Upload your SVG
Cropping happens in your browser.
Waiting for upload

Practical details

How Auto Crop SVG handles your file

SVG crop versus bitmap crop

The tool temporarily renders the SVG to find nontransparent pixels, then applies those bounds to the root viewBox. The downloaded file keeps its original SVG elements; they are not replaced with the measurement canvas.

Transparent margin versus white artwork

Only pixels at or below the transparency threshold count as empty. An opaque white rectangle is real artwork, even if it looks like blank space on a white preview, so it remains inside the crop.

Strokes, filters, and effects

Rendered strokes and browser-supported effects contribute visible pixels to the measured bounds. Very faint antialiasing, blur, or shadow pixels can fall below the chosen threshold; add padding when a soft effect needs breathing room.

Vector quality and dimensions

The crop changes the root viewBox, width, and height while retaining the SVG markup. Vector paths remain scalable. Any PNG or JPEG already embedded in the SVG remains raster at its original resolution.

Original oversized viewBox example

The blue rectangle occupies only the center of a 200 by 200 coordinate window. Tightening the window removes transparent margin without changing the rectangle itself.

Before
<svg viewBox="0 0 200 200">
  <rect x="30" y="40" width="140" height="120" fill="#2563eb"/>
</svg>
After
<svg viewBox="30 40 140 120" width="140" height="120">
  <rect x="30" y="40" width="140" height="120" fill="#2563eb"/>
</svg>

The shape coordinates are identical in both files. Only the root viewing window and intrinsic dimensions change.

Real limitations

  • Measurement uses a canvas capped at 2200 pixels on its longest side, so subpixel bounds are an approximation and can be rounded slightly.
  • Content already outside the original viewBox is clipped during rendering and cannot be recovered by the crop.
  • External images, unavailable fonts, or browser-unsupported SVG features may not appear in the measured render.
  • Files without a valid viewBox rely on inferred width and height; percentages, physical units, and unusual sizing deserve a manual result check.

What this tool does

Auto Crop SVG trims rendered transparent margin around visible artwork. It measures nontransparent pixels, then tightens the root viewBox, width, and height while keeping the original SVG elements in the downloaded file.

How it works

Upload an SVG, choose optional padding and a transparency threshold, and preview the measured crop. The tool uses a temporary browser canvas to find rendered bounds, then writes those bounds back to the SVG markup for download.

When to use Auto Crop SVG

Fixing an SVG with huge empty margins
Tightening an icon so it aligns in a layout
Cleaning up an export with an oversized viewBox
Prepping artwork before converting it to PNG

FAQ

Does it rasterize the SVG?

No. A temporary canvas measures visible pixels, but the download keeps the original SVG elements and changes the root viewBox, width, and height.

Does it remove a white background?

No. Opaque white shapes count as visible artwork. The crop removes transparent margin, not real white elements.

Can strokes or shadows be clipped?

Rendered strokes and effects are measured, but faint pixels can fall below the threshold. Lower the threshold or add padding when soft edges matter.

Why might a file still look misaligned?

Check for white or nearly transparent elements, transforms, external assets, content clipped by the original viewBox, and CSS baseline or container spacing around the SVG.