Aspect Ratio Calculator

Turn any width and height into a simplified ratio, or lock a ratio and scale one side to the size you need. Preview contain and cover, copy the CSS, compare two shapes, or check a whole batch without uploading a file.

Key Terms

Letterboxing
The bars left on the sides or above and below an image when it is fitted inside a frame with a different ratio.
Greatest common divisor
The largest whole number that divides both dimensions without a remainder. Dividing both sides by it produces the simplest form of a ratio.
Contain
A fit mode that scales an image until the whole image is visible inside the frame. Empty bars may appear when the source and frame ratios differ.
0files uploaded
2fit modes
6CSS units

How It Helps

%%

Fit before you crop

See the bars or the cropped area before committing, so the important part of an image is less likely to disappear.

CSS that ships

Copy a modern rule, a legacy fallback, or Tailwind classes without translating the numbers by hand.

No upload

Dimensions and image headers stay in the browser. The tool does not send a file or a size list to a server.

One-side scaling

Enter a width or a height and the tool solves the other side from the ratio, without manual cross-multiplication.

Exact reduction

The greatest common divisor produces the simplest whole-number ratio instead of a rounded approximation.

Shape comparison

Two ratios can be compared by decimal value and percent difference, which makes close formats easier to distinguish.

$

Useful presets

Video, social, device, print, and common formats are grouped together, with a custom field for anything else.

Immediate answers

The ratio, decimal value, and scaled side update while you type, with no submit button and no page reload.

All calculations run in your browser; no image or dimension list leaves your device.

How It Works

1

Enter a width and height

Type the dimensions in pixels, or choose an image and let the browser read its header. The simplified ratio and decimal value appear immediately.

2

Choose a target or lock the ratio

Select a preset or type a custom ratio, then enter the side you know. Add a scale percentage and a rounding rule if the output must land on whole or even pixels.

3

Copy the size or the CSS

Use the fit panel to check contain and cover, compare two shapes, or copy the generated CSS. The batch table handles a longer list when you need to audit many sizes.