Developer

Runs in your browser. No file uploads for processing.

Calculate SVG ViewBox Fit: Meet, Slice or Stretch

Preview SVG viewBox alignment, letterboxing and cropping. Get preserveAspectRatio and transform values.

Loading tool...

How to compare SVG viewBox fit settings

  1. Enter the viewBox and output viewport

    Use the four viewBox values from your SVG and the intended viewport width and height. Negative viewBox origins are supported.

  2. Compare meet, slice and none

    For a 120 × 80 viewBox in a 320 × 180 viewport, centered meet scales uniformly to 270 × 180 and leaves 25 pixels on each side. Slice fills the viewport and crops; none stretches to fit.

  3. Copy the attributes or export the numbers

    Use the generated viewBox and preserveAspectRatio attributes, or save the coordinate transform, visible rectangle and edge measurements as JSON.

Use cases

  • Diagnose unwanted padding around an SVG graphic in a fixed-width box.
  • Check which edges are clipped before choosing a cover-style crop.

Limits and privacy

  • Models a single rectangular viewport clipping its viewBox. Does not parse SVG files or account for CSS transforms, nested viewports, filters, strokes, browser zoom or visible overflow.
  • Letterbox padding is in viewport units and cropping is in source units. Values in the preview are rounded for readability.

The tool processes inputs in your browser. Account features and usage analytics are separate.

Frequently asked questions

What if I need to diagnose the path itself?

Use SVG Path Clinic for path geometry. The viewBox simulator computes viewport mapping from numeric inputs.

What is the difference between meet and slice?

Meet scales uniformly until the full viewBox fits; extra viewport space becomes padding. Slice scales uniformly until the viewport is covered, so some source area may be clipped.

Does preserveAspectRatio none preserve proportions?

Not necessarily. It uses separate horizontal and vertical scales, so the source can stretch.

Can the viewBox start at a negative coordinate?

Yes. The transform first accounts for the viewBox origin and then applies alignment in the viewport.

Why is padding not in the same units as crop?

Padding is unused space in the output viewport. Crop describes the source coordinates outside the visible rectangle.

Can I upload an SVG for this simulation?

No file is needed. Enter the numeric viewBox and viewport values; the preview only renders a generated diagram.

How is alignment represented in the output?

For meet and slice, Min, Mid and Max select each edge or center. With none, alignment is ignored because each axis fills the viewport.

Related tools