What is Aspect Ratio Calculator?
This aspect ratio calculator finds the matching dimension when you resize something without distorting it. An aspect ratio is the proportion between width and height: 16:9 for HD video, 4:3 for older screens and many photos, 1:1 for square social posts, 21:9 for ultrawide monitors and 9:16 for phone stories and reels.
Choose a preset or enter your own ratio, type the target width, and the tool calculates the height, rounded to whole pixels. It also gives you the CSS aspect-ratio property and HTML width and height attributes, so images and video embeds keep their shape and do not cause layout shift while loading.
How to use Aspect Ratio Calculator
- Pick a preset (16:9, 4:3, 1:1, 21:9 or 9:
- or enter your own width and height ratio.
- Enter the target width in pixels, such as
- Read the calculated height (1280 at 16:9 gives 720).
- Copy the CSS aspect-ratio rule or the HTML width and height attributes.
Key features
- Presets for 16:9, 4:3, 1:1, 21:9 and 9:16
- Custom ratios with any width and height values
- Height calculated instantly from the target width
- Ready-to-copy CSS aspect-ratio property
- HTML width and height attributes to prevent layout shift
Common use cases
- Resizing images and video for websites without distortion
- Sizing YouTube embeds (16:9) and phone stories or reels (9:16)
- Creating square (1:1) or 4:5 social media images
- Setting width and height on images to improve Core Web Vitals (CLS)
- Planning responsive layouts and hero banners
Technical details & standards
Height = width × (ratio height ÷ ratio width), rounded to the nearest pixel. For 16:9, a width of 1920 gives 1080 and 1280 gives 720; for 4:3, 1024 gives 768.
In CSS, aspect-ratio: 16 / 9 makes an element keep that shape at any width, which replaces the old padding-bottom: 56.25% trick. Setting width and height attributes on img and video elements lets the browser reserve the right amount of space before the file loads, which prevents layout shift and improves the Cumulative Layout Shift (CLS) Core Web Vital.
How to calculate the aspect ratio of any resolution
To calculate an aspect ratio from pixels, divide the width and height by their greatest common divisor. Here is 1366 × 768, a laptop size that is usually called 16:9:
- Find the greatest common divisor of 1366 and 768. Both are even, but 683 is not divisible by any factor of 384, so the divisor is 2.
- Divide both sides by 2: 1366 ÷ 2 = 683 and 768 ÷ 2 = 384.
- Compare the decimal ratio with the standard ones: 1366 ÷ 768 = 1.779, and 16 ÷ 9 = 1.778.
Result: 1366 × 768 is exactly 683:384, which rounds to 16:9. To scale a size instead, use height = width × 9 ÷ 16 for 16:9 or width × 3 ÷ 4 for 4:3, which is what the calculator above does.
Aspect ratio in CSS and JavaScript
In CSS the browser does the calculation for you; in JavaScript it is one multiplication and a rounding.
CSS
.video {
width: 100%;
aspect-ratio: 16 / 9; /* height follows the width */
}
.photo-4x3 {
aspect-ratio: 4 / 3;
object-fit: cover; /* crop instead of stretching */
}JavaScript
const heightFor = (width, rw, rh) => Math.round(width * rh / rw);
heightFor(1920, 16, 9); // 1080
heightFor(1440, 4, 3); // 1080Common screen and video resolutions
Popular sizes and the exact ratio each one reduces to. A 4:3 picture shown on a 16:9 screen keeps its height, so 1440 × 1080 sits inside 1920 × 1080 with bars at the sides. Some sizes sold as 16:9 or 21:9 are only close: 1366 × 768 is 683:384, and ultrawide monitors are 64:27 and 43:18.
| Resolution | Aspect ratio | Where it is used |
|---|---|---|
| 640 × 480 | 4:3 | VGA |
| 800 × 600 | 4:3 | SVGA |
| 1024 × 768 | 4:3 | XGA, older monitors and iPad screens |
| 960 × 720 | 4:3 | 4:3 video at 720 lines |
| 1440 × 1080 | 4:3 | 4:3 video at 1080 lines; fills a 16:9 screen with side bars |
| 1600 × 1200 | 4:3 | UXGA |
| 1280 × 720 | 16:9 | 720p HD |
| 1920 × 1080 | 16:9 | 1080p Full HD |
| 854 × 480 | 427:240 | 480p widescreen, a rounded 16:9 |
| 1366 × 768 | 683:384 | Budget laptop panels, sold as 16:9 |
| 2560 × 1440 | 16:9 | 1440p QHD |
| 3840 × 2160 | 16:9 | 4K UHD |
| 7680 × 4320 | 16:9 | 8K UHD |
| 1080 × 1080 | 1:1 | Square social media post |
| 1080 × 1350 | 4:5 | Portrait social media post |
| 1080 × 1920 | 9:16 | Stories, Reels and Shorts |
| 2560 × 1080 | 64:27 | Ultrawide monitor, sold as 21:9 |
| 3440 × 1440 | 43:18 | Ultrawide monitor, sold as 21:9 |
Frequently asked questions
What is 16:9 in pixels?
Any size where the width is 16/9 of the height. Common 16:9 resolutions are 1280 × 720 (720p), 1920 × 1080 (1080p), 2560 × 1440 (1440p) and 3840 × 2160 (4K UHD).
How do I calculate height from width and aspect ratio?
Divide the width by the ratio's width and multiply by its height. For a 4:3 image that is 800px wide: 800 ÷ 4 × 3 = 600px tall.
How do I keep an element's aspect ratio in CSS?
Use the aspect-ratio property, for example .video { width: 100%; aspect-ratio: 16 / 9; }. The browser sets the height from the width automatically. It is supported in all current browsers.
What aspect ratio should I use for social media?
Use 1:1 or 4:5 for feed posts, 9:16 for Stories, Reels, TikTok and YouTube Shorts, and 16:9 for YouTube videos and most link-preview images.
How do I convert 4:3 to 16:9?
Not without changing the picture. Either crop the top and bottom, so a 1440 × 1080 frame becomes 1440 × 810, or keep the whole frame and add black bars at the sides to fill 1920 × 1080. Choose 16:9 in the calculator and enter a width to get the matching height.
What are the 4:3 and 16:9 heights for the same width?
Multiply the width by 3 ÷ 4 for 4:3 and by 9 ÷ 16 for 16:9. At 1280 px wide that is 960 px versus 720 px, at 1920 px it is 1440 px versus 1080 px, and at 3840 px it is 2880 px versus 2160 px. The 4:3 frame is always a third taller.
Is my data safe?
Processing happens locally in your browser. Tool input is not sent to CodeUnpack servers.
Does it work offline?
Once the page has loaded, this tool can process input without an internet connection.