dp ↔ px converter

Pick a density and both values follow each other.

Values

px = dp × (density dpi ÷ 160). sp uses the same value as dp and then scales with the user's font size setting.

How dp and px relate

A dp (density-independent pixel) is sized so that it looks the same on screens of different densities. The baseline is 160 dpi, where 1 dp is exactly 1 px. As density goes up, more physical pixels are used to draw the same dp — that multiplier is what the table below lists.

Density buckets

BucketdpiScale48 dp
mdpi16048 px
hdpi2401.5×72 px
xhdpi32096 px
xxhdpi480144 px
xxxhdpi640192 px

Why there is no sp field

sp (scale-independent pixel) is the unit for text and its formula is the same as dp. The only difference is that it is multiplied again by the user's font size setting, and that factor lives on the device — we cannot know it here. A third field would just repeat the dp number. At a font scale of 1.0, sp equals dp.

Which side recalculates when the density changes

dp is held and px is recomputed. Changing the density asks "how many pixels is this same dp on that screen", not "convert whatever I typed last".

How is the share link built

Share builds a link that carries the values you entered. Opening it fills the same fields and shows the result right away, so the person you sent it to does not have to type anything. The values are plain to see in the address, so editing the link by hand is fine too — anything out of range simply opens the empty calculator.

Similar tools All tools →