CSS Unit Converter
Convert between PX, REM, EM, VW, VH, and % CSS units — with configurable base font size and live conversion.
Last updated: March 25, 2026
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat is CSS Unit Converter?
CSS has many unit types, each suited to different layout and typography scenarios. Absolute units like px (pixels) are fixed regardless of context. Relative units like rem and em scale based on font sizes — rem relative to the root (html) element, em relative to the nearest ancestor with an explicit font size. Viewport units (vw, vh, vmin, vmax) scale relative to the browser window dimensions. Choosing the right unit type directly impacts your site's accessibility (users who change their browser font size preference), responsive behaviour, and layout stability.
The most common conversion developers need is px ↔ rem for typography and spacing. When a designer hands over a spec in pixels (font-size: 32px) and your codebase uses rem-based spacing (to respect user font preferences), you need to divide by the base font size: 32px ÷ 16px = 2rem. This tool automates all such conversions simultaneously, updating all unit equivalents in real time as you type, with a configurable base font size for designs that use a non-standard root (like 10px for 1rem = 10px convenience).
How to Use CSS Unit Converter
Set the base font size at the top (default is 16px — the browser standard)
Type a value in any unit field (PX, REM, EM, %, VW, VH)
All other unit fields update in real time showing the converted equivalents
Click any output field to copy the value to your clipboard
Change the base font size to recalculate all values instantly for your specific root element size
Common Use Cases
- Converting a pixel-based design spec to REM units for accessible, scalable typography
- Verifying that a spacing value (16px) stays consistent when converted to rem (1rem at base 16px)
- Calculating the viewport-width equivalent of a fixed pixel width for fluid typography
- Converting a legacy EM-based component to REM to avoid compounding EM inheritance issues
- Checking how a component size in pixels relates to viewport width on a 1440px wide design
- Designing spacing scales (8px, 16px, 24px, 32px) and showing their rem equivalents for CSS custom properties
- Converting a designer's 10px base font size to the rem values the browser will render at 16px
- Teaching CSS unit types by showing the mathematical relationships between all unit types simultaneously
Example Input and Output
Converting font and spacing values from a pixel design spec into different CSS units:
Base font size: 16px
Input values to convert: 14px, 16px, 24px, 32px, 48px14px → 0.875rem | 0.875em | 1.458vw (at 960px viewport)
16px → 1rem | 1em | 1.667vw (at 960px viewport)
24px → 1.5rem | 1.5em | 2.500vw (at 960px viewport)
32px → 2rem | 2em | 3.333vw (at 960px viewport)
48px → 3rem | 3em | 5.000vw (at 960px viewport)Client-Side Processing
All unit conversions run locally via JavaScript arithmetic. No values are sent to our servers.
Browser Font Size Default
Never assume users' default font size is exactly 16px. About 3% of users change their browser's base font size. Always test your layout with the browser font size preference changed to "Large" or "Very Large" in settings to verify that your REM-based spacing and typography scale gracefully.
Avoid EM for Spacing
Avoid using EM for padding and margin on containers, as the compounding effect becomes extremely difficult to debug. If you set margin: 1em on a button inside an article with font-size: 1.2em inside a section with font-size: 1.1em, the actual margin is 1em × 1.2 × 1.1 = 1.32em of the root. Use REM or use px for spacing to keep layouts predictable.
Frequently Asked Questions
What is the difference between REM and EM?
Why should I use REM instead of PX?
What is the root font size and how do I change it?
What are VW and VH units?
What does "EM for font size, REM for spacing" mean?
What is the clamp() function and how does it relate to these units?
How This Tool Works
The conversion logic is pure arithmetic. The tool reads the base font size input and uses it as the denominator for REM and EM calculations. A configured viewport width (default 1440px) is used for VW/VH calculations. When a value is typed into any unit field, the equivalent value in all other units is computed: px ÷ baseFontSize = rem, px ÷ viewportWidth × 100 = vw, etc. All computed values are displayed synchronously in their respective input fields.
Technical Stack