PX to Tailwind Spacing Converter
Find the closest Tailwind CSS spacing class for any pixel value.
What Is PX to Tailwind Spacing Converter?
When translating a design into Tailwind CSS, you need the utility class that best matches a pixel measurement. This tool divides your px value by (root font size ÷ 4) and finds the nearest valid step on Tailwind's default spacing scale, so you get classes like p-4, gap-6, or m-8 instantly.
How to Convert PX to Tailwind Spacing?
Divide your pixel value by (root font size ÷ 4) to get the ideal step, then round to the nearest value on Tailwind's default spacing scale (0, px, 0.5, 1, 1.5, 2, … 96). At 16px root, divide px by 4 to get the step number.
How to use the PX to Tailwind Spacing converter
- 1
Enter the pixel value from your design mockup, Figma frame, or browser inspector.
- 2
Adjust root font size if your site uses a custom html font-size. This affects which Tailwind step matches.
- 3
Use the closest match class (p-, m-, gap-, w-, h-) shown below. Exact matches are highlighted when your px hits a scale step.
PX to Tailwind Spacing Formula
Common PX Values: Nearest Tailwind Spacing Class
| Pixels | Tailwind Step | Exact px | REM | Class |
|---|---|---|---|---|
| 1px | px | 1px | n/a | p-px |
| 2px | 0.5 | 2px | 0.125rem | p-0.5 |
| 4px | 1 | 4px | 0.25rem | p-1 |
| 6px | 1.5 | 6px | 0.375rem | p-1.5 |
| 8px | 2 | 8px | 0.5rem | p-2 |
| 10px | 2.5 | 10px | 0.625rem | p-2.5 |
| 12px | 3 | 12px | 0.75rem | p-3 |
| 14px | 3.5 | 14px | 0.875rem | p-3.5 |
| 16px | 4 | 16px | 1rem | p-4 |
| 20px | 5 | 20px | 1.25rem | p-5 |
| 24px | 6 | 24px | 1.5rem | p-6 |
| 28px | 7 | 28px | 1.75rem | p-7 |
| 32px | 8 | 32px | 2rem | p-8 |
| 36px | 9 | 36px | 2.25rem | p-9 |
| 40px | 10 | 40px | 2.5rem | p-10 |
| 48px | 12 | 48px | 3rem | p-12 |
| 56px | 14 | 56px | 3.5rem | p-14 |
| 64px | 16 | 64px | 4rem | p-16 |
| 72px | 16 | 64px | 4rem | p-16 |
| 80px | 20 | 80px | 5rem | p-20 |
| 96px | 24 | 96px | 6rem | p-24 |
| 128px | 32 | 128px | 8rem | p-32 |
| 192px | 48 | 192px | 12rem | p-48 |
| 256px | 64 | 256px | 16rem | p-64 |
| 384px | 96 | 384px | 24rem | p-96 |
See the full scale with Tailwind Spacing to PX or convert px to rem with PX to REM.