Mr.AndroidShin / Dev Tools

Android · Layout units

dp / sp / px Converter

Enter a value, pick its unit and a screen density, and get the equivalent in dp, sp and px — with a full density-bucket table and a font-scale option for sp.

Needed to convert to and from px.
1.00×
User's system font size. 1.00× = default.
px @ selected density
48
dp
16
sp @ scale
16
Ad slot — insert your AdSense unit here

px across every density bucket

For the value above, here is the pixel size on each Android density bucket. The row matching your selected density is highlighted.

BucketDensityMultiplierpx

How the conversion works

Android measures layout in dp (density-independent pixels). One dp equals one physical pixel on a 160 dpi (mdpi) screen, and scales up on denser screens. The core formula is:

px = dp × (dpi ÷ 160)

So on an xxhdpi (480 dpi, 3×) screen, 16 dp = 48 px. To go the other way, divide: dp = px ÷ (dpi ÷ 160).

What about sp?

sp (scale-independent pixels) behaves like dp but is also multiplied by the user's font-size setting. Use sp for text so it respects accessibility preferences. At a font scale of 1.00×, sp and dp are identical; at 1.30×, text set in sp renders 30% larger. This tool applies the font scale only where sp is involved.

Density buckets at a glance

mdpi 1× (160), hdpi 1.5× (240), xhdpi 2× (320), xxhdpi 3× (480), xxxhdpi 4× (640). Most modern phones are xxhdpi or xxxhdpi.

FAQ

Is 1 dp always 1 px?

Only at mdpi (160 dpi). On every denser bucket, 1 dp maps to more than one physical pixel.

Should I use dp or sp?

Use dp for layout dimensions (margins, sizes) and sp for text. sp additionally scales with the user's font-size setting, which dp does not.

How do I find my device's density?

It maps to a bucket by dpi range. In code, resources.displayMetrics.densityDpi gives the exact value; pick the closest bucket in the table above.

Does this store my input?

No. Everything is computed in your browser and nothing is uploaded.

Ad slot — insert your AdSense unit here