b2KIT

SVG ViewBox Editor

Adjust SVG viewBox, dimensions, and coordinate system with visual preview.

Tested tool guide Tested browser tools Checked August 16, 2026

What SVG ViewBox Editor does, with a checked example

Every SVG carries two independent rectangles: width and height, which size the element on the page, and viewBox, which selects the slice of the drawing that fills it. This tool takes your markup, puts the viewBox, width, and height into editable fields, and redraws the artwork after every change so you can watch the coordinate window slide across the drawing. The detail most people get wrong: content outside the viewBox is not shrunk to fit, it is clipped entirely, which is exactly how a healthy SVG can render as an empty box.

Worked example

A concrete input and expected output from the current implementation.

Input

<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="50 50 100 100">
  <rect x="0" y="0" width="40" height="40"/>
</svg>

Expected output

The preview renders an empty 100x100 box. The viewBox '50 50 100 100' maps the user-coordinate window x 50-150, y 50-150 onto the full viewport, and the rect spans only x 0-40, y 0-40, entirely outside that window, so every pixel is clipped. With viewBox '0 0 100 100' the same rect occupies the top-left 40x40 pixels.

A viewBox names the rectangle of the drawing that fills the element; everything outside is cut, not compressed. The rect's bounds do not intersect the visible window, so nothing survives.

How the result is produced

1

The four numbers, decoded

viewBox='min-x min-y width height' names a rectangle in the drawing's own coordinate space, and the element's width and height attributes form the viewport that rectangle is scaled into. Points inside the rectangle are visible; points outside are clipped, not compressed. Nonzero min-x or min-y slides the window across the artwork, which is why the picture moves while no shape coordinate changes.

2

Mapping and aspect ratio

The default mapping preserves the viewBox's proportions: the scale is the smaller of the two viewport-to-viewBox ratios and the drawing is centered, so a square viewBox inside a wide viewport leaves empty bands on the sides. Editing any field changes the mapping and the preview repaints immediately, showing the window shift or the bands appear. Everything runs locally in the browser tab; the markup is never uploaded.

Good uses

  • A downloaded icon renders tiny in one corner of its box because its viewBox is far larger than the artwork. Tighten the viewBox to the artwork's bounding box so the icon fills the frame.
  • An exported chart arrives cropped or empty because the file's viewBox starts at a large min-x or min-y, leaving the artwork outside the visible window. Pull the window origin back toward 0 0 to reveal it.
  • A square logo must become a wide banner. Widen the viewBox, adding empty user space on the sides, instead of stretching the width attribute, and use the preview to check for letterbox bands from the ratio mismatch.

Limits and checks

  • Enlarging width and height does not add canvas around the artwork; it rescales the drawing to fit the bigger viewport. To add margin, widen the viewBox.
  • Letterbox bands are default behavior, not a bug: a viewBox whose aspect ratio differs from the viewport is fitted uniformly and centered. Filling the bands means matching the ratios or setting preserveAspectRatio to none, which distorts.
  • The editor changes attributes, not geometry. Shape coordinates in the markup stay as authored, so copying a path into another file keeps the original points; only the element's rendering respects the new viewBox.

Common questions

My SVG renders blank even though the markup looks fine. What is wrong?

The viewBox picks the part of the drawing the element shows, and anything outside is clipped. If every shape falls outside the window, the result is an empty box. Compare the viewBox bounds with your shapes' coordinates - under viewBox='50 50 100 100', a shape at x 0-40 is invisible. Lowering the origin or widening the window usually brings it back.

Will editing the viewBox distort my shapes?

Not by itself. The default mapping scales uniformly and centers the result, so proportions hold and any mismatch shows as empty bands instead. Shapes only stretch when the element sets preserveAspectRatio to none, which the preview shows immediately. A viewBox that matches the viewport ratio is the safe way to fill the frame without stretching.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools