SVGFlow
Open editor

Resize SVG & fix viewBox

Resize an SVG online: set width and height, fix a missing viewBox, or rebuild one from the drawing's real bounding box.

Runs entirely in your browser — nothing is uploaded, no account needed.

Previewno file
Drop an SVG to resize
Or paste markup below · max 2 MB
Result
Open an SVG to see the result.
Box
viewBox
Rendered size

How it works

The tool edits the root <svg> element only — width, height, viewBox and preserveAspectRatio — and never touches the drawing inside. Because SVG is resolution-independent, that is all resizing an SVG ever needs to be: change the declared box and every path re-renders sharp at the new size, with no resampling and no quality loss. Type into a field to set the attribute; clear a field and the attribute is removed from the file, which is itself a useful operation. The lock keeps width and height proportional to the file's intrinsic ratio while you type, the result is shown as formatted markup before you commit it, and everything runs in your browser — nothing is uploaded. Applying writes the shared document, so the resized file flows straight into the editor or an export.

viewBox and width/height do different jobs

The viewBox defines the coordinate system: which rectangle of the drawing's own units is visible. width and height define the box on the page that rectangle is mapped into. Confusing the two is behind most SVG sizing bugs. A file with only width and height is pinned at that size — scaling it in CSS crops rather than zooms. A file with only a viewBox scales to whatever contains it. A file with both renders at the declared size by default and scales when CSS says otherwise. That is why this tool treats them as separate controls rather than one "size" field, and why removing an attribute is as important as setting one. The viewBox guide works through which attribute wins in which context.

The two ways to rebuild a viewBox

From width/height writes 0 0 w h using the dimensions currently in the form. That is the right move for the common export bug — a file with width="48" height="48" and no viewBox at all — because those editors drew the content against that box from the origin; you are writing down the coordinate system the file always assumed.

From content asks the browser to measure where the drawing actually is: the file is mounted invisibly for a frame, getBBox() reports the true bounding box of everything painted, and that becomes the viewBox. This is the fix when the drawing sits nowhere near the origin — a shape cut out of a larger illustration, an icon whose coordinates start at 400 — and it doubles as a crop-to-content: whatever empty margin the export left around the artwork is gone, which matters when an icon has to sit optically tight in a button. One caveat is inherent to getBBox(): it measures geometry, not paint, so stroke overhang, markers and filter effects like shadows fall outside the derived box. Widen the numbers by hand when the artwork paints past its skeleton.

Making an icon scale to its container

The most requested "resize" is not a size at all — it is making a fixed-size icon fluid. The recipe is two steps on this page: make sure a correct viewBox exists (derive one if not), then press Clear width & height and apply. With only a viewBox left, the SVG sizes to its CSS container — width: 1em makes it track the text size, 100% fills a layout slot, and the same file serves every size from favicon to hero. The preserveAspectRatio field covers the remaining case where container and viewBox proportions differ: the default xMidYMid meet letterboxes, slice fills and crops, and none stretches. If you leave the field empty the attribute stays out of the file, which is almost always right.

When to use it

An icon that refuses to scale: fixed dimensions and no viewBox is the usual cause, and the fix is derive-from-dimensions, then clear width and height. A drawing that renders off-centre or clipped after editing, where the viewBox no longer matches where the content actually sits: derive from content. A print-bound export whose pt or mm dimensions come out the wrong size on screen: retype them as plain numbers. And setting an exact box before a PNG export — though if the SVG itself is fine and only the PNG needs to be bigger, set the pixel size in that tool instead and leave the file alone.

Common problems

  • The derived box clips strokes. getBBox() measures geometry, not paint — a stroke overhangs its path by half its width on every side, and shadows and markers are not counted at all. Pad the numbers after deriving.
  • Setting width and height changes nothing on the page. CSS wins over attributes. The attributes only provide the default size for contexts with no stylesheet — an <img>, a download, an email.
  • Deriving from dimensions produced an empty view. The content is not drawn at the origin, so 0 0 w h frames the wrong region. Derive from content instead — it starts from where the drawing actually is.
  • The drawing is distorted after applying. With the lock off, the width/height ratio no longer matches the viewBox ratio, and preserveAspectRatio decides how the mismatch resolves. Either relock, or set it deliberately.
  • The numbers inside the paths didn't change. By design — resizing SVG means changing the mapping, not rewriting coordinates. The drawing's own units are untouched, which is why the operation is exact and reversible.

Questions

Is this SVG resizer free?

Yes. Resizing and viewBox repair are free, with no account, no watermark and no file limit. The site is funded by advertising.

Does resizing an SVG lose quality?

No. An SVG is instructions, not pixels — resizing changes the declared box and the drawing re-renders exactly at the new size. There is no resampling, no blur and no upscaling penalty, whether you go from 16 px to 16,000 or back.

How do I resize an SVG to exact pixel dimensions?

Type the width and height and apply — those attributes are the file’s default rendered size. Keep the lock on to preserve the aspect ratio; with it off, mismatched proportions are resolved by preserveAspectRatio, which letterboxes by default.

How do I make an SVG scale to fit its container?

Ensure the file has a correct viewBox, then use Clear width & height and apply. With only a viewBox, the SVG takes its size from CSS — 1em, 100%, anything — and one file serves every size. This is the standard setup for icons.

What is the viewBox, in one sentence?

It is the rectangle of the drawing's own coordinate system that gets shown — four numbers: minimum x, minimum y, width and height — and the browser maps that rectangle into whatever box the SVG occupies on the page. The viewBox guide goes deeper.

My SVG has no viewBox — can this add one?

Yes, two ways. From width/height writes 0 0 w h, matching what the exporter assumed; From content measures the real bounding box of the drawn artwork with the browser’s getBBox() and frames exactly that. Use the second when the drawing is not at the origin.

Can I crop an SVG to its content?

Effectively, yes. From content sets the viewBox to the artwork’s measured bounds, so surrounding empty space is no longer part of the visible box. Note that getBBox() ignores stroke overhang and shadows — widen the values a little if the artwork paints past its geometry.

Does it change the paths inside the file?

No. Only the four root attributes — width, height, viewBox and preserveAspectRatio — are written. The geometry keeps its own units, which is what makes the operation exact, and reversible by simply setting the old values again.

Why does my resized SVG still render at the old size on my page?

CSS beats attributes. If a stylesheet or an inline style sets the element’s size, the attributes only serve as the fallback for unstyled contexts. Change the CSS, or remove it and let the attributes speak.

What does preserveAspectRatio do?

It decides what happens when the viewBox proportions and the box proportions disagree: xMidYMid meet (the default) fits the whole drawing and letterboxes, slice fills the box and crops the overflow, and none stretches to fit. Leave the field empty to keep the attribute out of the file.

Is my file uploaded when I resize it?

No. The attributes are rewritten by your own browser and the result is shown before you apply it. Nothing leaves your machine.

Notes

  • viewBox defines the coordinate system; width and height define the box on the page. They answer different questions — there is a guide on which one wins.
  • Removing width and height while keeping viewBox is what makes an icon scale to its container.
  • Deriving from content uses the browser’s own getBBox(), which measures geometry only — a stroke that overhangs the shape is not counted, so add padding if you need it inside the box.

Related tools