DP, SP, and PX: Android and iOS Density Units
Understand density-independent pixels, how dp and sp convert to px across Android buckets, and how iOS points compare.
Overview
Phones and tablets pack wildly different numbers of physical pixels into the same physical inch. A budget phone might have 160 pixels per inch while a flagship has 480 or more. If you sized a button in raw pixels, it would look finger-friendly on one device and tiny on another. Density units solve this: you design in a density-independent unit and the system multiplies it into the right number of pixels for each screen. The PX to DP Converter does that multiplication for you.
Try the PX to DP Converter →Why density units matter
A dp (density-independent pixel) always describes the same physical size no matter how dense the screen is. That means a 48dp touch target is comfortably tappable on every Android device, because the platform scales it up on high-density screens automatically. Designing in dp keeps layouts consistent across the whole device catalog instead of breaking on the next phone that ships with a sharper display.
How the conversion works
Android defines mdpi (160 dots per inch) as the baseline, where 1dp equals 1px. Every other bucket is a multiple of that baseline. The formula is simply px = dp times (density / 160):
- ldpi (120dpi) = 0.75x
- mdpi (160dpi) = 1x (baseline)
- hdpi (240dpi) = 1.5x
- xhdpi (320dpi) = 2x
- xxhdpi (480dpi) = 3x
- xxxhdpi (640dpi) = 4x
sp (scale-independent pixels) uses the exact same math but is reserved for text, because it also responds to the user's font-size accessibility setting. In other words, sp and dp use the same pixel math but different purposes, which is why px to sp and px to dp give identical numbers here. That shared multiply-by-density rule is the whole of density unit conversion, and it is what android density buckets encode. iOS follows the same idea with points and integer @1x, @2x, and @3x scale factors.
Examples
Here is the PX to DP Converter in action. For example, say a redline specifies 8dp of spacing. On an mdpi screen that is 8px, on an xhdpi screen it is 16px, and on an xxxhdpi screen it is 32px. As another example, a 24dp icon becomes 24, 36, 48, 72, and 96px across the buckets. Going the other way, if you measure 32px in a screenshot taken on an xhdpi device, dividing by the 2x scale recovers 16dp. On iOS, a 10pt element renders at 10, 20, and 30px for @1x, @2x, and @3x.
Common mistakes
- Treating dp as a fixed pixel count. 1dp is only 1px at mdpi; it grows with density. Always convert per bucket.
- Using dp for text. Body text should use sp so it honors the reader's font-size preference. Reserve dp for layout dimensions.
- Exporting one raster size. A single PNG will blur on high-density screens. Export per bucket, or use vector drawables that scale cleanly.
Comparisons and alternatives
The PX to DP Converter is for native mobile work. If you are building for the web instead, reach for the PX to REM Converter, where the analogous idea is sizing in rem so type scales with the browser font setting. And when you need to size whole screens or images to a fixed proportion, the Aspect Ratio Calculator solves the missing dimension. Comparing the PX to DP Converter vs alternatives, single-bucket dp tools show one density at a time, while this one shows every Android density and the iOS point scales at once, so one measurement covers both platforms.
Private and offline
Every conversion is arithmetic that runs in your browser. Nothing is uploaded, and the tool keeps working with no connection once loaded, so it fits neatly into any mobile design workflow.
Related Tools
You May Also Need
You may also need
- PX to REM ConverterConvert the same measurement into CSS units for the web
Next steps
- Aspect Ratio CalculatorSize screens and images while holding a ratio
Alternatives
- PX to REM ConverterWhen the target is CSS rem and em rather than native units