Read the current values first
adb shell wm size adb shell wm density
Write both values down before you change anything. The size output is the physical resolution and the density output is the value the system is currently using. If the density is not one of 120/160/240/320/480/640, that is normal — many phones report intermediate values like 420 or 440.
Set a new density
adb shell wm density 440
Lower values make everything larger because fewer pixels fit in a dp; higher values make everything smaller. Stay within roughly 10–15% of the density your device reports by default. Beyond that, some system apps start drawing outside their allotted bounds.
Undo it
adb shell wm density reset
This returns the density to the device default without a reboot. Note that reset is different from setting the value you wrote down earlier: setting a number pins it, while reset clears the override entirely so future ROM updates behave normally.
If you have no cable
Wireless debugging works for this on Android 11 and later. Enable developer options, turn on wireless debugging, pair with the code shown in the settings screen, then connect with adb connect host:port. The density commands are identical once connected.
If the UI becomes unusable
A density far from the native value can make the screen look almost blank. Do not panic and do not factory reset: the override lives in settings, not in the boot image. Reboot into recovery is not needed either. Connect over adb again, which still works, and run wm density reset, then reboot.
If adb no longer connects, booting into safe mode temporarily disables third-party apps but keeps the density override — the reliable fix is to remove the override via adb from a computer, so keep the cable nearby when experimenting.
Want to know what a candidate density does to your layout before you apply it? The dp ↔ px converter shows exactly how many pixels each dp becomes at that density.