dp/sp to px Converter

Convert Android dp, sp, and dip values to pixels per density bucket.

Loading tool…

dp/sp to px Converter on Loonix helps you convert dp, sp, and dip values to pixels across every Android density bucket, with the font scale applied so the sp result matches the user preference.

How to use

  1. Enter the dp or sp value from your layout file.
  2. Set the font scale to match the accessibility setting you are testing for.
  3. Read the pixel value for each density bucket you need to support.

Features and limitations

  • Covers all six density buckets with the dpi values Android itself maps them to.
  • Floors the result the way Android does, so a converted value cannot grow a layout by a pixel.
  • Applies the user font scale to sp values, which is what makes sp differ from dp.
  • Also converts back from pixels to dp at mdpi for checking against a layout file.

Limitation: Covers plain dp, sp, and dip values. Values inside ConstraintLayout, wrap_content, or with a maximum width are resolved by the layout engine at runtime and can differ.

Use cases

  • Convert a dp value from a layout while working without Android Studio.
  • Check how a dimension changes across screen densities.
  • Work out the pixel value a user with a large system font will actually get.

Frequently asked questions

Usage, result, and limitation information for this tool.

Why is the result rounded down instead of to the nearest pixel?
Rounding up widens a layout by one pixel, and one extra pixel is enough to produce a horizontal scrollbar the designer did not ask for. Android itself floors when converting dp to pixels.
Why do dp and sp give different numbers?
sp multiplies by the font scale the user set in accessibility settings, while dp does not. They only match when the font scale is 1.
What is mdpi?
The baseline at 160dpi, where one dp equals one pixel. Every other bucket scales from that number.
Does this match what Android actually renders?
Yes, for a plain dp or sp value with no other configuration. Values inside ConstraintLayout or after a font scale change follow the same rule but are resolved at layout time.

Cookies and analytics

We use Google Analytics to learn which pages are useful, and Google AdSense to cover server costs. Both set cookies. You can decline; ads will still appear, just fewer of them and less relevant.