AyeCalc
All tools
Tailwind CSS

Tailwind Spacing Converter

Translate a Tailwind spacing multiplier such as 4, 6, or 8 into its CSS length. The default reflects Tailwind CSS v4's 0.25rem spacing variable and remains configurable for custom themes.

Tailwind v4 modelCustom theme supportUtility examples
Tailwind CSS v4

Convert a spacing utility

Custom theme ready

REM1.51.5rem
Pixels2424px at this root
Multiplier6times --spacing
p-6m-6gap-6w-6h-6
Generated CSS value
calc(var(--spacing) * 6)
Core formulalength = spacing number × --spacing

With --spacing: 0.25rem and a 16px root, spacing 4 equals 1rem or 16px.

01
Method

How the tailwind spacing converter works

Multiply the numeric utility value by the configured --spacing theme variable. Convert rem to pixels by multiplying by the root font size.

Formulalength = spacing number × --spacing

With --spacing: 0.25rem and a 16px root, spacing 4 equals 1rem or 16px.

02
Worked example

Convert Tailwind spacing 6 with the default theme variable

Spacing 6 multiplied by 0.25rem equals 1.5rem. At a 16px root font size, the computed equivalent is 24px, as in p-6 or gap-6.

03
Implementation

Copyable code examples

Use these examples as a starting point, then match the values and assumptions to the rendered project.

Tailwind HTML
<div class="p-6 gap-6">
  <!-- 1.5rem with the default spacing variable -->
</div>
Tailwind theme
@import "tailwindcss";

@theme {
  --spacing: 0.25rem;
}
Generated CSS model
.p-6 {
  padding: calc(var(--spacing) * 6);
}
04
Practical guidance

Using the result accurately

Check the --spacing value in the actual project before treating a lookup as fixed. Tailwind v4 derives many numeric spacing utilities dynamically, and a custom theme can change every result.

Important limitation

This tool converts numeric spacing utilities. Keywords, fractions, arbitrary values, container sizes, and project-specific utility definitions may follow different rules.

References: Tailwind CSS spacing documentation.

Common questions

Tailwind Spacing Converter FAQ

Answers about the method, assumptions, and practical use.

What is Tailwind's default spacing variable?

Tailwind CSS v4 derives numeric spacing utilities from --spacing, shown as 0.25rem in the default framework output. Projects can customize it.

How many pixels is p-4?

With --spacing set to 0.25rem, p-4 is 1rem. At a 16px root font size, that computes to 16px.

Does this work for negative margin utilities?

The magnitude uses the same spacing calculation. A negative utility applies the negative of that result.

Does it cover arbitrary values like p-[18px]?

No conversion is needed for arbitrary values because the value is written directly. This calculator targets numeric utilities derived from --spacing.