Skip to content
FastTool

Why an SVG gets cropped or refuses to scale, and how to fix viewBox

A missing or tight viewBox clips outer strokes and freezes CSS scaling, while unitless 72 dpi exports open at 75% size.

Updated · Uses the free SVG Optimizer & Cleaner, which runs in your browser

Short answer

Three issues cause almost every broken SVG. Without viewBox="min-x min-y width height", fixed width and height values freeze CSS scaling. Next, SVG centers strokes on the path: a 4 px stroke on 0 0 24 24 spans −2 to 26, needing viewBox="-2 -2 28 28". Finally, CSS sets 96 px = 1 in = 25.4 mm, so 72 dpi Illustrator exports open at 75% size. Fix all three in the SVG Optimizer & Cleaner.

Open the SVG Optimizer & Cleaner

How viewBox controls scaling and cropping

W3C SVG 2 separates an image’s outside slot (the viewport) from its inside ruler (the user coordinate system). On the root <svg> tag, viewBox="min-x min-y width height" names the top-left corner and span of that inside ruler.

When an editor writes width="128px" height="128px" with no viewBox, 1 inside unit stays glued to 1 screen pixel. Making the container wider in CSS opens empty space instead of enlarging the drawing.

How browsers and cutting apps read root SVG sizing attributes
Root attributes on <svg> Browser CSS behavior Best use
width and height only (no viewBox) Locked at 1 user unit = 1 px; clips anything below 0 or past width and height Avoid; add a matching viewBox first
viewBox only (width and height removed) Scales smoothly to fill any CSS width or flex/grid box while keeping aspect ratio Web icons, logos and inline HTML graphics
width, height in mm/in + viewBox Locks physical size (for example 80 mm ÷ 80 units = 1 mm per unit) Inkscape, Cricut, LightBurn and print templates

In the default example of the SVG Optimizer & Cleaner, a 3,826-byte Inkscape shield icon carries width="128px" height="128px" and no viewBox. Responsive mode writes viewBox="0 0 128 128", drops both pixel attributes and shrinks the file to 655 bytes (−82.9%).

Worked example: why a 4 px stroke clips on a 24 × 24 icon

W3C SVG 2 Section 13.4 centers every stroke on the geometric path. Half of stroke-width falls inside the shape and half reaches outside.

Suppose a 24 × 24 icon draws a rounded square from 0 to 24 with stroke-width="4". Because 4 ÷ 2 = 2 user units protrude past all four edges, the painted ink runs from −2 to 26:

min = 0 − (4 ÷ 2) = −2, span = 24 + 4 = 28.
Result: viewBox="-2 -2 28 28"

Open the SVG Optimizer & Cleaner with the Clipped stroke without viewBox preset loaded to see both previews side by side:

  1. The original 651-byte badge has width="24" height="24", no viewBox, and a 4 px border on 0 to 24. In the Original box, the top and left strokes slice in half and the icon stays stuck at 24 px.
  2. With Expand viewBox when outer strokes clip ticked, the tool measures path and stroke bounds across lines, curves and arcs.
  3. It sets viewBox="-2 -2 28 28" and outputs a 305-byte responsive SVG (−53.1%) with all four rounded borders intact.

Why 72 dpi Illustrator SVGs open at 75% size in Inkscape and Cricut

W3C CSS Values and Units fixes the reference pixel at 96 px = 1 in = 25.4 mm. One millimeter equals 3.7795 px, and one point equals 1/72 in (1.3333 px). Modern browsers, Inkscape (since 0.92), Cricut Design Space and LightBurn’s 96 dpi mode all follow that ratio.

Adobe Illustrator’s internal ruler uses PostScript points (72 pt = 1 in). A 100 mm square measures 100 ÷ 25.4 × 72 = 283.465 pt. When Illustrator exports viewBox="0 0 283.465 283.465" without millimeter attributes, a 96 dpi app reads 283.465 units as pixels:

imported mm = 283.465 × (25.4 ÷ 96) = 75.00 mm   (72 ÷ 96 = 75% of 100 mm)
How a 100 mm part imports when an SVG omits physical mm or in attributes
Exporting program User units for 100 mm Size in a 96 dpi app Scale to restore 100 mm
Adobe Illustrator / Corel 72 dpi (1 pt = 1 unit) 283.465 75.00 mm (75%) 133.333% (× 4/3)
Inkscape 0.91 and older (90 dpi) 354.331 93.75 mm (93.75%) 106.667% (× 16/15)
W3C CSS / Inkscape 0.92+ (96 dpi) 377.953 100.00 mm (100%) 100% (× 1)
Millimeter user units (width="100mm" + viewBox="0 0 100 100") 100.000 100.00 mm (100%) 100% in every app

To keep cut files exact during cleanup, open the laser preset in the SVG Optimizer & Cleaner. Choosing Keep width, height and viewBox at 3 decimals shrinks the 80 × 50 mm plate from 1,936 bytes to 542 bytes (−72.0%). Every hole and slot stays locked at 1 unit = 1 mm. Need custom ratios or multi-sheet paper templates? Use the Scale Calculator, Poster & Pattern Tiler or Image Resizer.

When widening viewBox is the wrong fix

  • Pixel-aligned icon sets. Widening 0 0 24 24 to −2 −2 28 28 shrinks the shape inside a 24 px button to 24 ÷ 28 = 85.7%. To keep optical weight matched across a toolbar, inset the rectangle to x="2" y="2" width="20" height="20" in your vector editor instead.
  • Laser and CNC parts with physical units. On a millimeter cut file, leave Expand viewBox when outer strokes clip unticked. That way a hairline preview stroke never shifts the 1:1 millimeter scale.

Sources

Spotted a mistake in this guide? Email contact@fasttool.app. We reply within 7 business days.

Open the SVG Optimizer & Cleaner