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.

Why Android uses dp instead of pixels

If you sized everything in raw pixels, a 48-pixel button would look finger-friendly on an old low-density screen and shrink to a tiny target on a modern high-density one — same pixel count, wildly different physical size. dp fixes this by describing size in density-independent units, so 48 dp is roughly the same physical size on every screen. The system multiplies dp by the screen's density to arrive at the real pixel count for you. Designing in dp is what lets one layout look consistent across a cheap phone, a flagship, and a tablet.

The 48 dp touch-target rule

A practical reason this conversion matters: Android's accessibility guidance recommends interactive elements be at least 48 dp on a side, which works out to about a 9mm physical target — roughly the pad of a finger. Because that's in dp, it holds across densities. When you check a design against that minimum, you're checking dp, not pixels; this converter shows you what that 48 dp becomes in physical pixels on each bucket, which is handy when you're slicing assets or debugging why a control feels too small on one device.

Where sp changes the picture

The reason text uses sp and everything else uses dp is accessibility. A user who sets a larger system font expects your text to grow with it — sp makes that happen automatically, dp does not. The trade-off is that sp text can overflow a fixed-size dp container at large font scales, which is a common source of clipped labels. Previewing your text at a higher font scale (this tool lets you apply one) catches that before a user with large fonts does.

Ad slot — insert your AdSense unit here