Skip to content
ToolShedby Wasim Shaikh

SVG viewBox Cropper & Resizer

Trim empty whitespace around any SVG, center it in a 1:1 square, or normalize it to a 24×24 or 32×32 icon grid in your browser.

Trim empty space around the artwork.

0 units
2 decimals

Expands bounds by half the widest stroke so outlines are never clipped.

How to Crop an SVG viewBox

  1. Paste or upload an SVG. Paste SVG markup or drop an .svg file exported from Figma, Illustrator, or Sketch.
  2. Pick a crop mode. Use Tight crop to trim all whitespace, Square (1:1) to center the icon, or Fit to grid (24×24, 32×32, etc.) to standardize an icon set.
  3. Adjust padding and strokes. Add uniform padding if needed, and keep "Account for stroke width" enabled so outlined icons are not clipped at the edges.
  4. Copy or continue. Copy the updated SVG, download it, or send it straight to the SVG Optimizer, JSX Converter, or PNG Exporter.

Which Crop Mode Should You Use?

ModeWhat it doesBest for
Tight cropSets viewBox to the exact bounding box of visible shapes plus optional padding.Logos, illustrations, and removing uneven artboard margins.
Square (1:1)Expands the shorter side to match the longer side and centers the artwork.Favicons, avatars, and mixed-aspect icons in buttons.
Fit to gridSets viewBox="0 0 N N" (e.g. 24×24) and wraps artwork in a centered <g transform>.Standardizing third-party icons into a uniform icon system.

Frequently Asked Questions

How does the cropper measure the SVG?
It temporarily renders your SVG offscreen in your browser and calls the native SVGGraphicsElement.getBBox() API. Nothing is uploaded to a server.
Why does Tight crop or Square leave my paths untouched?
Both modes only recalculate the root viewBox attribute (and optionally width/height), so your path coordinates and strokes stay 100% intact.
Why are stroked icons clipped without stroke padding?
In SVG, getBBox() measures the geometric centerline of a path, not its stroke thickness. Enabling "Account for stroke width" expands the box by half the widest stroke so rounded caps and outer borders stay inside the frame.
When should I remove width and height?
Removing width and height lets CSS control the icon size (for example class="w-5 h-5") while the updated viewBox preserves the exact aspect ratio.

Sources & Standards

Last reviewed .

Related Tools

Need an icon to start from? Browse Material Symbols, Lucide, Heroicons, the free CC0 icon packs or this week's new icons.