PX to DP
Convert pixels to density-independent pixels (DP/DIP) and scale-independent pixels (SP) for Android development. Supports all screen densities (mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi).
Runs entirely in your browser — files never uploaded
| Density | Qualifier | Scale | DPI | PX | DP | SP (text) | |
|---|---|---|---|---|---|---|---|
| Low | ldpi | 0.75x | 120 | 48 | 64 | 64 | |
| Mediumbaseline | mdpi | 1x | 160 | 48 | 48 | 48 | |
| High | hdpi | 1.5x | 240 | 48 | 32 | 32 | |
| Extra-high | xhdpi | 2x | 320 | 48 | 24 | 24 | |
| XX-high | xxhdpi | 3x | 480 | 48 | 16 | 16 | |
| XXX-high | xxxhdpi | 4x | 640 | 48 | 12 | 12 |
DP, SP, and PX explained
PX (Pixels)
Physical pixels on screen. The actual dots rendered. Varies across devices with different screen densities.
DP (Density-independent Pixels)
Abstract unit that normalizes across screen densities. 1 dp = 1 px on a 160 dpi (mdpi) screen. Use for layouts, padding, margins, and icon sizes.
SP (Scale-independent Pixels)
Same as DP but also scales with the user's preferred text size. Always use SP for android:textSize to support accessibility.
Formula
dp = px / (dpi / 160) — px = dp × (dpi / 160)
How to use PX to DP
- 1. Enter a value. Type a pixel or DP value into the input field.
- 2. Choose direction. Toggle between PX to DP and DP to PX conversion modes.
- 3. Read results. The table shows converted values for every Android density bucket, including SP for text sizing.
FAQ
What is the difference between DP and SP?
DP (density-independent pixels) scales with screen density. SP (scale-independent pixels) also respects the user's font-size preference, so SP should be used for text and DP for everything else.
Which density bucket should I target?
Design at mdpi (1x / 160 dpi) as the baseline. Android automatically scales assets to match the device density. Provide assets for each bucket to keep graphics sharp.
How is the DP formula calculated?
dp = px / (dpi / 160). For example, 48 px on a 320 dpi (xhdpi) screen equals 24 dp.
When should I use SP instead of DP?
Use SP for any text size (android:textSize). This ensures your text respects the user's system-wide font-size setting for accessibility.
Related tools
- Base64 EncoderEncode text or files to Base64 or decode Base64 back online for free. Instant conversion, no signup, runs in your browser.
- JSON FormatterFormat and validate JSON online for free. Beautify with indentation, validate syntax, or minify. Runs in your browser, no signup.
- CSV ↔ JSONConvert CSV to JSON or JSON to CSV online for free. Live preview as you type or upload a file. No signup, runs in browser.
- Timestamp ConverterConvert Unix timestamps to dates and dates to timestamps online for free. Supports seconds, milliseconds, ISO 8601. No signup.
- JWT DecoderDecode JWT tokens online for free. Inspect header, payload, and claims. Verify expiration and signature algorithm. No signup, runs in browser.
- Regex TesterTest regular expressions online for free with live match highlighting, capture groups, and flag toggles. Supports JavaScript regex. No signup.