CSS Type Scale, Spacing and Unit Converter
Choose a base size and scale ratio, set the viewport range, and copy font sizes in px, rem and responsive clamp() CSS, plus unit conversions and spacing.
Runs in your browser. Your files never leave your device. See how to check
…
How to do it
- 1Set the base size
Usually 16 px.
- 2Choose ratios
Desktop and mobile.
- 3Set the viewport range
Smallest and largest.
- 4Copy the CSS
px, rem or clamp().
- 5Convert values
px to rem, pt and vw.
About this tool
Good typography uses a small set of related sizes rather than random ones. A modular scale multiplies a base size by a ratio for each step: with a 16 px base and a ratio of 1.25 (a major third), the steps are 20, 25, 31.25, 39 px and so on. Fluid typography goes further: CSS clamp() lets headings grow smoothly between a mobile and a desktop scale. This toolkit builds the scale, writes the clamp() values, converts px to rem, em, pt and vw, and creates a matching spacing ladder.
Who this is for
Web designers, front-end developers, design system builders and students learning CSS.
Modular scales
Size at step n = base × ratio^n. Common ratios come from musical intervals: 1.067 minor second, 1.125 major second, 1.2 minor third, 1.25 major third, 1.333 perfect fourth, 1.414 augmented fourth, 1.5 perfect fifth and 1.618 golden ratio. Smaller ratios suit dense interfaces; larger ratios suit editorial pages.
Fluid sizes with clamp()
Choose a smaller ratio for the narrowest viewport and a larger one for the widest. For each step, the calculator finds the straight line between the two sizes and writes clamp(min, intercept + slope vw, max). Text grows smoothly between 375 px and 1,440 px wide screens and stops at the limits. Using rem for the limits respects the user's browser font setting.
Unit conversions
rem = px / root font size (usually 16). pt = px × 0.75. vw = px / viewport width × 100. em equals rem only when the parent font size equals the root.
Spacing scale
Consistent spacing uses multiples of a base unit, usually 4 or 8 px. The calculator lists a ladder from half a unit to 16 units: with 8 px, 4, 8, 12, 16, 24, 32, 48, 64, 96 and 128 px.
A worked example
With a 16 px base and ratio 1.25 on desktop and 1.2 on mobile, step 4 is 39.06 px on desktop and 33.2 px on mobile: clamp(2.074rem, 1.944rem + 0.553vw, 2.441rem). 24 px is 1.5 rem and 1.875 vw on a 1,280 px screen.
Accessibility
Avoid fixed px for body text; rem sizes scale with user preferences. Check that body text stays at least 16 px on mobile.
## Line height and measure Pair the scale with line heights of about 1.5 for body text and 1.1 to 1.25 for large headings, and keep lines between 45 and 75 characters. These are design conventions, not rules.
## Exporting tokens Copy the table into CSS custom properties, such as --step-1, or into design tokens for Figma.
Limits
Visual design still needs judgement. The values are mathematical guides, not design advice.
Worked example
Step 4 of a 16 px, 1.25 scale is 39.06 px, or clamp(2.074rem, 1.944rem + 0.553vw, 2.441rem) when fluid.
Quick facts
- Category: Developer & Data
- Works in your browser, no sign-up, no upload.
- Your input stays on your device.
- Available in English.
- Content last reviewed:
- Official source: W3C CSS Values and Units Module Level 4 (rem, vw, clamp())
Frequently asked questions
What is a modular scale?
Font sizes made by multiplying a base size by a ratio for each step.
Which ratio should I use?
1.2 to 1.25 for interfaces; 1.333 or more for editorial pages.
How do I convert px to rem?
Divide by the root font size, usually 16.
What does clamp() do?
It sets a minimum, a fluid preferred value and a maximum.
Should spacing use 4 or 8 px?
Either; 8 px is common, 4 px gives finer control.
Is my data stored?
No. It stays in your browser.
