dp to px converter for every Android screen density
Convert dp, sp and px instantly for mdpi, hdpi, xhdpi, xxhdpi and xxxhdpi – or any custom dpi. See every density at once, with font scaling for sp and iOS point sizes too.
| Density | dpi | Scale | px | dp | sp |
|---|
Tap a px value to copy it. Formula: px = dp × (dpi ÷ 160), and px = sp × (dpi ÷ 160) × font scale.
dp, sp and px explained
px are real screen pixels. dp (density-independent pixels) are what Android layouts use: 1 dp is one pixel on a 160 dpi (mdpi) screen, so a 48 dp button looks the same physical size on every phone. sp (scale-independent pixels) work like dp but also follow the user’s font size setting – always use sp for text.
Android density buckets
| Bucket | dpi | 1 dp equals | Launcher icon (48 dp) |
|---|---|---|---|
| ldpi | 120 | 0.75 px | 36 px |
| mdpi | 160 | 1 px | 48 px |
| hdpi | 240 | 1.5 px | 72 px |
| xhdpi | 320 | 2 px | 96 px |
| xxhdpi | 480 | 3 px | 144 px |
| xxxhdpi | 640 | 4 px | 192 px |
Convert in code
In Kotlin with Jetpack Compose you rarely convert by hand – use 16.dp and 14.sp, and inside a composable with(LocalDensity.current) { 16.dp.toPx() }. In the View system: TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16f, resources.displayMetrics).
Handy sizes to remember
- 48 dp – minimum touch target in Material Design.
- 8 dp grid – most spacing in Material is a multiple of 8 (or 4 for small details).
- 14–16 sp – normal body text; 12 sp is the smallest comfortable size.
- 360 dp – a typical phone width in dp.
Frequently asked questions
How do I convert dp to px?
px = dp × (dpi ÷ 160). On an xxhdpi phone (480 dpi), 16 dp = 16 × 3 = 48 px.
What is the difference between dp and sp?
Both scale with screen density, but sp also scales with the user’s font size setting. Use sp for text and dp for everything else.
How do I find my phone’s dpi?
Turn on Developer options and check “Smallest width”, or use an app that shows display metrics. In code, read resources.displayMetrics.densityDpi.
Is 1 dp the same as 1 iOS point?
They are very close in purpose. Both are about 1/160 inch on a reference screen. iOS @2x screens use 2 px per point and @3x screens use 3 px.
Why does sp text get bigger on some phones?
Because the user has a larger font size in Accessibility settings. Android 14 and later can scale fonts up to 200%, and large text scales a little less than small text, so test your layouts with big font sizes.
Need a website or app built?
We design and build websites and Android apps for clients worldwide – clear scope, fixed price, fast delivery.
Techpass Master Technologies · Websites, Android apps and digital marketing
