Free online tools

SVG ViewBox Calculator

Turn the width, height and origin of your SVG artwork into a viewBox. Add equal padding or expand the bounds to fit a viewport ratio.

Enter your values

Used in viewport ratio mode.

Used in viewport ratio mode.

This tool processes your input in your browser.

Result

Use four values for the SVG viewBox

The first two values give the origin of the visible region in SVG units. The last two give its width and height. A negative origin is valid if the artwork extends left or above the drawing origin.

Expand the shorter dimension for a target ratio

The viewport-ratio mode grows whichever viewBox dimension is too small and splits the extra area evenly across its two sides. It preserves the padded drawing inside the result.

Frequently asked questions

Does the viewBox have to use pixels?

The four values are in the SVG’s internal coordinates. The viewport is the area on screen or in a layout where the SVG is displayed.

Does the padding change my artwork?

It changes the visible coordinate window. It does not move the paths or other drawing elements.