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
- Paste or upload an SVG. Paste SVG markup or drop an .svg file exported from Figma, Illustrator, or Sketch.
- 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.
- 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.
- 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?
| Mode | What it does | Best for |
|---|---|---|
| Tight crop | Sets 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 grid | Sets 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
SVG to JSX ConverterTurn any SVG into a React (JSX/TSX), Angular, Vue or Svelte component with a size prop and currentColor. SVGO cleanup built in; nothing is uploaded.SVG OptimizerCompress SVG files with SVGO 4 in your browser. Before/after size, gzip size and preview, plus batch optimize up to 200 files to a .zip.SVG to CSS Data URIConvert any SVG into a compact URL-encoded CSS Data URI or Base64 for background-image, mask-image (currentColor), and CSS variables.SVG to PNG, ICO & FaviconExport an SVG as a sharp PNG, WebP or JPG at any size, a multi-size .ico, or a complete favicon set with Apple touch icon, maskable icons and manifest.mat-icon SVG Migration HelperMove Angular Material mat-icon from the icon font to SVG: rewrites templates to svgIcon, downloads only the Material Symbols you use, and writes the MatIconRegistry code.
Need an icon to start from? Browse Material Symbols, Lucide, Heroicons, the free CC0 icon packs or this week's new icons.