Utility

Unit Converters

Android display & battery math. Live as you type.

  • Runs locally
  • Works offline
  • No sign-up

Unit converters

px, dp, sp, DPI and PPI

px ↔ dp ↔ sp

DPI density bucket

Screen PPI

Battery charge time (estimate)

All conversions run locally. Nothing is uploaded.

About this tool

Four live calculators for Android display and battery math: pixel/dp/sp conversion, the nearest density bucket for a DPI, screen PPI from resolution and diagonal, and a rough battery charge-time estimate.

Every field recalculates as you type. Treat the charge estimate as a ballpark, since real charging slows down as the battery fills (the CV phase).

What are dp, sp & DPI?

  • dp (density-independent pixel): a virtual unit where 1dp = 1px at 160 DPI. Use it for layout so UI is the same physical size on any screen.
  • sp (scale-independent pixel): like dp but also scales with the user's font-size setting. Use it for text.
  • DPI (dots per inch): pixel density. Android maps it to buckets such as mdpi, hdpi, and xhdpi.
  • PPI: the true pixel density of a physical screen, from its resolution and diagonal.

Tips

  • The formula is px = dp × (dpi / 160). At 160 DPI they're equal.
  • Design layouts in dp and text in sp, and never hard-code px.
  • DPI buckets are nominal; a phone reporting 420 DPI sits between xhdpi and xxhdpi.
  • Charge time uses watt-hours / effective watts. Lower the efficiency value for heat/cable losses.

About the Android Unit Converters

Android UI and hardware work runs on a handful of recurring calculations. This page bundles four of them into live converters that recompute as you type, with no rounding errors copied from a forum and no spreadsheet. Everything runs locally in your browser.

Pixels, dp and sp

A dp (density-independent pixel) is the unit you design layouts in. By definition 1dp = 1px at 160 DPI, and on any other screen px = dp × (dpi / 160). That keeps a 48dp button the same physical size whether it's on a cheap 160-DPI tablet or a 560-DPI flagship. sp (scale-independent pixel) is the same idea for text, but it also scales with the user's font-size setting, so always size fonts in sp.

DPI buckets and PPI

Android maps a screen's density to the nearest bucket (mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi) so you can ship the right-resolution drawables. PPI (pixels per inch) is the true physical density, computed from the resolution and the diagonal: sqrt(w^2 + h^2) / diagonal.

Battery charge time

The estimate converts capacity to watt-hours (mAh / 1000 x voltage) and divides by the charger's effective wattage. It's deliberately rough: real charging slows in the constant-voltage (CV) phase near full, so treat the number as a floor, not a promise.

Frequently asked questions

What's the difference between dp and px?

px is a raw physical pixel; dp is density-independent (1dp = 1px at 160 DPI). Designing in dp keeps your UI the same physical size on every screen.

When do I use sp?

Always use sp for text sizes. It scales with the user's accessibility font setting, which dp does not. Use dp for everything else.

Why is my phone's DPI between two buckets?

Buckets are nominal anchor values. A 420-DPI phone sits between xhdpi (320) and xxhdpi (480); Android picks the nearest bucket for resource selection while using the real density for measurements.

Why doesn't the charge-time match reality?

The model ignores the CV taper, heat, and cable losses. Lower the efficiency value to get closer to real-world times; it's a ballpark, not a spec.