Unit-To-Unit Pixels conversion www.cupandgear.com

DP to PX

1 dp = 1 CSS pixels

One Android dp equals one CSS pixel for layout purposes: both are density-independent references at 160 and 96 nominal dpi respectively, scaled by the device pixel ratio.

Formula px = dp × 1

=

Type in either field — the other updates on every keystroke. Need other units? Open the full pixels converter.

DP to PX — quick reference
Android dp (160 dpi)CSS pixel
1 dp1 px
2 dp2 px
3 dp3 px
4 dp4 px
5 dp5 px
10 dp10 px
15 dp15 px
20 dp20 px
25 dp25 px
50 dp50 px
100 dp100 px
500 dp500 px
1000 dp1000 px
PX to DP — reverse
CSS pixelAndroid dp (160 dpi)
1 px1 dp
2 px2 dp
3 px3 dp
4 px4 dp
5 px5 dp
10 px10 dp
15 px15 dp
20 px20 dp
25 px25 dp
50 px50 dp
100 px100 dp
500 px500 dp
1000 px1000 dp

Worked examples

Common values
Screen densityFromTo (device pixels)
mdpi (160 dpi, 1×)48 dp48 px
hdpi (240 dpi, 1.5×)48 dp72 px
xhdpi (320 dpi, 2×)48 dp96 px
xxhdpi (480 dpi, 3×)48 dp144 px
xxxhdpi (640 dpi, 4×)48 dp192 px

What a dp really is

Android layouts are written in dp so they look the same on every screen.

A dp, short for density-independent pixel, is Android's unit for layout sizes. It is defined against a baseline screen of 160 dots per inch, where 1 dp is exactly one physical pixel. On a denser screen the system scales the dp up: at 320 dpi (the xhdpi bucket) 1 dp is 2 device pixels, and at 480 dpi (xxhdpi) it is 3. The idea is that a 48 dp button should look about the same size in the hand whether the phone has a modest or a very sharp display.

On the web the same idea shows up as the CSS pixel, which is also a reference unit and not a hardware pixel. That is why this converter treats 1 dp as 1 CSS px: if you design a layout in CSS pixels and an Android layout in dp, the two come out the same logical size. The physical dots that light up are a different matter and depend on the device's density.

Density buckets and scale factors

Android groups screens into density buckets with a scale factor relative to the 160 dpi baseline: ldpi 0.75× (120 dpi), mdpi 1× (160 dpi), hdpi 1.5× (240 dpi), xhdpi 2× (320 dpi), xxhdpi 3× (480 dpi) and xxxhdpi 4× (640 dpi). To get device pixels, multiply dp by the scale factor. A 16 dp margin is 16 px on mdpi, 32 px on xhdpi and 48 px on xxhdpi.

Most current phones fall in the xhdpi to xxxhdpi range, so artwork is usually exported at 2×, 3× and 4× of its dp size. A 24 dp icon needs a 24 px file for mdpi, 48 px for xhdpi, 72 px for xxhdpi and 96 px for xxxhdpi. Supplying all of them keeps icons sharp without the system having to scale them.

Designing touch targets in dp

Because dp tracks physical size, it is the right unit for touch targets. Android's Material guidance recommends at least 48 × 48 dp for anything tappable, which works out to roughly 7 to 9 mm on a typical phone, close to the size of a fingertip pad. If an icon looks like 24 dp, keep the touch area at 48 dp by adding padding rather than enlarging the icon.

Spacing follows the same logic. Many design systems use an 8 dp grid, so margins and paddings come in steps of 4, 8, 16, 24 and 32 dp. These numbers carry across platforms, and they map directly to CSS pixels if you build the same interface for the web.

dp, sp and CSS units

Text on Android is sized in sp (scale-independent pixels), which behave like dp but also follow the user's font-size setting. If a user sets a larger font, text in sp grows, while elements in dp stay the same. The web equivalent is rem, which scales with the root font size. When you move a design from Android to the web, convert dp to CSS px for fixed sizes, and sp to rem for text.

To convert a dp value to device pixels for a specific phone, you need its density. Look up the device's reported density (for example 2.625 on some phones), multiply, and round to the nearest whole pixel, since the system rounds when it lays out views.

Moving a design between Android and the web

A phone that is 360 dp wide is also about 360 CSS pixels wide in a mobile browser, because both units are density-independent. That is why design tools use common viewport widths of 360, 375, 390 and 412 for phones. A layout designed in dp can be implemented in CSS pixels almost unchanged, as long as you set the viewport meta tag so that the browser uses the device width.

Images are the exception. In Android you export bitmaps for each density bucket, while on the web you use srcset to give the browser a choice of 1×, 2× and 3× files. In both cases the file's pixel size is the dp size times the density: a 100 dp wide image should be 200 px wide for a 2× screen and 300 px for a 3× screen.

dp to CSS px: common Android sizes
SituationFromTo
Grid unit8 dp8 px
Small margin16 dp16 px
Icon size24 dp24 px
Touch target48 dp48 px
App bar height56 dp56 px
Typical phone width360 dp360 px

Mental-math shortcut and common mistakes

Device pixels = dp × (screen dpi ÷ 160). On a 2× screen, double the dp figure.

Do not confuse dp with sp. Text is sized in sp, which also follows the user's font setting, while dp does not.

Background

Android defines one dp as one physical pixel on a 160 dpi (mdpi) screen, and scales it up on denser displays.

Learn more

Related guides: Digital and print layout units: px, rem, em, points and DPI · Unit conversion formulas by category · Where unit conversions come up in daily life

Frequently asked

How many CSS pixels are in a dp?
1 dp = 1 CSS pixels. In the other direction, 1 CSS pixel = 1 dp.
What is a dp?
An Android density-independent pixel equals one physical pixel at 160 dpi, and is functionally equivalent to a CSS pixel for layout purposes.
What is a CSS pixel?
A CSS pixel is a reference unit of 1/96 inch, not a physical device pixel. Browsers scale it by the device pixel ratio, so one CSS pixel may cover four hardware pixels on a 2× display.
How many pixels is 48 dp?
In CSS terms, 48 px. On device it depends on density: 48 px at mdpi, 96 px at xhdpi and 144 px at xxhdpi.
Is 1 dp equal to 1 px?
On a 160 dpi (mdpi) screen, yes. On the web, this converter treats 1 dp as 1 CSS px. On denser Android screens 1 dp is 1.5 to 4 device pixels.
What is the difference between dp and sp?
dp sizes layouts, while sp sizes text and also follows the user's font-size setting.
What size should a touch target be?
Material Design recommends at least 48 × 48 dp.