Ratio Calculator
Pixel Ratio Calculator | RatioCalculator.org

Pixel Ratio Calculator

Convert CSS pixels to real device pixels with our free online pixel ratio calculator. Enter your layout dimensions and device pixel ratio (DPR) to see the true physical resolution — essential for responsive web design, Retina image optimization, and canvas rendering.

Calculate Now
🔍

Interactive Pixel Ratio Calculator

Layout width in CSS pixels (what your stylesheet uses).
Layout height in CSS pixels.
Common values: 1 (standard), 2 (Retina), 3 (Super Retina). In a browser console, type window.devicePixelRatio to read yours.

Physical Pixel Results

Physical Resolution
—
Total Physical Pixels
—
Megapixels
—
Display Class
—
Image Asset Guidance
—

How the Pixel Ratio Calculator Works

Four steps from CSS pixels to physical pixels

1

Enter CSS Dimensions

Type the width and height your layout uses — the CSS pixel values from your stylesheet, Figma frame, or media query breakpoints. These are resolution-independent units.

2

Set the Device Pixel Ratio

Enter the DPR directly or pick a common device from the preset list. DPR 1 means one device pixel per CSS pixel; DPR 3 means nine device pixels (3×3) render each CSS pixel.

3

Read Physical Pixels

The calculator multiplies each dimension by the DPR to reveal the true hardware resolution, plus total pixels and megapixels — the numbers that determine image sharpness.

4

Optimize Your Assets

Use the guidance to size images correctly: serve assets at the physical resolution (or use srcset) so Retina screens get crisp graphics without wasting bandwidth on standard displays.

Pixel Ratio Formulas Explained

The math between CSS and hardware pixels

Physical Pixels Formula

Physical Pixels = CSS Pixels × Device Pixel Ratio

Applied per dimension: a 390 × 844 CSS layout on a DPR 3 iPhone renders at 1170 × 2532 physical pixels. The ratio applies linearly to width and height — and quadratically to total pixel count.

Total Pixels and Megapixels

Total = (W × DPR) × (H × DPR) = W × H × DPR²

Megapixels = Total ÷ 1,000,000. Notice the DPR is squared: moving from DPR 1 to DPR 2 quadruples the pixels the GPU must shade, which is why high-DPR rendering costs battery and performance.

Required Image Resolution

Image Width Needed = Display CSS Width × DPR

An image displayed at 300 CSS px wide needs to be 600 px wide for DPR 2 and 900 px for DPR 3 to look sharp. Serving a 300 px image on a DPR 3 screen stretches each image pixel across 9 device pixels — the classic "blurry on Retina" problem.

Learn more: The MDN documentation on window.devicePixelRatio explains how browsers expose this value to JavaScript.

Common Devices and Their Pixel Ratios

DPR values you will encounter in the wild

DeviceCSS ResolutionDPRPhysical Resolution
Standard 24" desktop monitor1920 × 108011920 × 1080
MacBook Air 13" (Retina)1440 × 90022880 × 1800
iPhone 15 Pro393 × 85231179 × 2556
Pixel 8412 × 9152.6251080 × 2400
iPad Pro 11"834 × 119421668 × 2388
4K desktop monitor (scaled)1920 × 108023840 × 2160
Budget Android phone360 × 6401.5–2540×960 – 720×1280

Responsive Image Strategy by DPR

What to serve at each pixel density

DPRImage StrategyExample (300 CSS px image)
1Serve at 1×, standard compression300 px wide file
1.5Serve 1.5× or use srcset 1x/2x450 px wide file
2Serve 2× via srcset600 px wide file
3Serve 3×; consider AVIF/WebP to control weight900 px wide file
Note: DPR can be fractional (2.625, 1.75) on Android. Browsers handle the rounding — size your srcset candidates to the ceiling of CSS × DPR and let the browser pick.

Testing Your Site Across Pixel Densities

A practical QA checklist

1

DevTools Device Toolbar

Chrome and Firefox device emulation lets you switch DPR between 1, 2, and 3 instantly. Load your page at each setting and screenshot-compare hero images, logos, and product shots for softness.

2

Real Device Spot-Checks

Emulation misses GPU quirks. Check at least one DPR-1 desktop, one DPR-2 laptop, and one DPR-3 phone physically. Pay special attention to thin icon strokes and small text rendered as images.

3

Network Panel Audit

With device emulation set to DPR 3, watch the Network panel: the browser should request your 3× srcset candidates, not the 1× fallbacks. If it fetches small files on a dense screen, your sizes attribute is wrong.

Pixel Ratio FAQs

DPR questions from developers and designers

Device pixel ratio is the number of physical device pixels that fit into one CSS pixel, per dimension. A DPR of 2 means a 2×2 grid of hardware pixels renders each CSS pixel. Apple markets DPR-2 displays as "Retina" because individual pixels become indistinguishable at normal viewing distances.

Open your browser's developer console and type window.devicePixelRatio — it returns the current value (try zooming the page; it changes). On mobile, it reflects the screen hardware; on desktop, OS display scaling affects it (e.g., 125% scaling on Windows gives DPR 1.25).

Your desktop likely has DPR 1 while the phone has DPR 2 or 3. An image sized exactly to its CSS display size has enough pixels for DPR 1 but only a third of what's needed at DPR 3, so the phone upscales it and it looks soft. Serve higher-resolution variants with srcset.

No — a 3× image is roughly 9× the file weight of the 1× version, punishing DPR-1 users with slow loads for zero visual benefit. Use responsive images (srcset + sizes) so each device downloads only the resolution it can actually display.

Yes, directly. A canvas defaults to CSS-pixel resolution, so graphics look blurry on Retina screens unless you scale the canvas backing store by devicePixelRatio (canvas.width = cssWidth × DPR) and scale the context. The same applies to WebGL framebuffers — multiply by DPR for crisp rendering.

PPI (pixels per inch) is a hardware density — how many physical pixels fit in an inch of screen. DPR is a software ratio — how many of those physical pixels map to one CSS pixel. A 400 PPI phone and a 100 PPI monitor can both report DPR 2; the phone just packs its pixels far more densely.

In practice, browsers report a minimum around 0.5–1. Very old or unusual displays aside, DPR below 1 is essentially nonexistent on modern devices. Values you will actually see: 1, 1.25, 1.5, 2, 2.625, and 3.

Designing for a Multi-DPR World

The CSS pixel was invented to free designers from hardware. When Apple introduced the iPhone 4 with double-density display in 2010, existing websites would have rendered at half size if pixels stayed physical — so the industry decoupled the CSS pixel from the device pixel, and the device pixel ratio was born as the bridge between them. Every responsive design decision since lives on that bridge.

The practical consequence is a two-track workflow. Layout happens in CSS pixels — breakpoints, spacing, typography all use the abstract unit, which is why a 390 px-wide phone layout works identically on DPR 2 and DPR 3 screens. Assets happen in physical pixels — images, canvas art, and icon exports must be sized to CSS × DPR, which is exactly what this calculator computes. Confusing the two tracks is the root cause of nearly every "looks blurry on mobile" bug.

Modern best practice is the srcset/sizes pattern: provide the same image at 1×, 2×, and 3× widths and let the browser choose based on DPR and viewport. Pair it with modern formats (AVIF, WebP) to keep the higher-density variants affordable in bytes. For vector content — SVG icons, icon fonts, CSS shapes — DPR is irrelevant because vectors rasterize at the native density automatically; prefer them wherever possible.

One more subtlety: DPR interacts with browser zoom. Zooming to 200% doubles the effective DPR, which is why a page can look sharper zoomed in — and why testing at multiple zoom levels is a quick way to audit whether your image strategy holds up. The calculator above gives you the numbers; your eyes on real devices give you the verdict.

Scroll to Top