CSS Unit Converter
Convert between CSS units like px, rem, em, vh, vw. Free, fast, and works entirely in your browser with no sign-up required.
Updated
CSS Unit Converter
Convert between all CSS units — px, rem, em, vw, vh, vmin, vmax, pt, pc, cm, mm, in, ex, ch — with real-time conversion tables, typography & spacing scales, responsive clamp() generator, device presets, breakpoint calculator, and Tailwind CSS equivalents.
Input
Device Viewport Presets
Viewport: 1440×900px
All Units — Real-time Conversion
| Unit | Name | Value | CSS | Tailwind | |
|---|---|---|---|---|---|
px | Pixels | 16 | 16px | 4 | |
rem | Root EM | 1 | 1rem | 4 | |
em | EM | 1 | 1em | 4 | |
vw | Viewport Width | 1.11111 | 1.11111vw | ||
vh | Viewport Height | 1.77778 | 1.77778vh | ||
vmin | Viewport Min | 1.77778 | 1.77778vmin | ||
vmax | Viewport Max | 1.11111 | 1.11111vmax | ||
pt | Points | 12 | 12pt | 4 | |
pc | Picas | 1 | 1pc | 4 | |
cm | Centimeters | 0.42333 | 0.42333cm | 4 | |
mm | Millimeters | 4.23333 | 4.23333mm | 4 | |
in | Inches | 0.16667 | 0.16667in | 4 | |
ex | x-height | 2 | 2ex | 4 | |
ch | Character Width | 1.66667 | 1.66667ch | 4 | |
% | Percentage | 1.11111 | 1.11111% | 4 |
Frequently Asked Questions
How do I convert px to rem?
To convert pixels to rem, divide the pixel value by the root font-size, which browsers set to 16px by default. So 24px is 24 / 16 = 1.5rem, 12px is 0.75rem, and 32px is 2rem. The reason developers move from px to rem is accessibility: rem scales with a visitor's chosen browser font-size, while hard-coded pixels ignore it, so text stays readable for people who zoom or enlarge fonts. If your project uses a different root size, the math changes, so the divisor must match your actual html font-size. This converter does it instantly across every unit at once, lets you set a custom root font-size instead of assuming 16px, and flags the matching Tailwind class (for example 16px maps to text-base) so you can paste straight into a utility-class codebase.
What is the difference between em and rem in CSS?
Both are relative font-size units, but they measure against different things. A rem is always relative to the root element's font-size, so 1rem equals the same pixel value everywhere on the page regardless of nesting. An em is relative to the font-size of the current element, which means it compounds: if a parent is 1.2em and a child inside it is also 1.2em, the child renders at roughly 1.44 times the base, and deeper nesting multiplies further. That compounding makes em useful for component-local scaling like padding that tracks its own text, but it can cause surprises in deep trees, where rem stays predictable. This tool lets you set both the root font-size and the parent font-size separately, so you can see exactly how an em value resolves in your specific nesting context versus a rem.
How many pixels are in 1 inch, 1pt, and 1cm in CSS?
CSS uses a fixed reference standard rather than your monitor's real physical size, so the absolute units are defined relative to each other. By that standard 1 inch equals 96px and 72pt, which makes 1pt roughly 1.333px and 1pc (pica) exactly 16px since 1pc is 12pt. For metric units, 1cm is about 37.8px (96 divided by 2.54) and 1mm is about 3.78px. These conversions are most relevant in print stylesheets, where points and physical units genuinely map to paper, while on screens an inch is a CSS abstraction, not a measured inch. Rather than memorising these factors or doing the arithmetic by hand, paste any value into this converter and it returns the equivalent across px, pt, pc, cm, mm, and in simultaneously with one-click copy.
What is the difference between vmin and vmax in CSS?
Both are viewport units equal to 1% of a viewport dimension, but they pick different dimensions. vmin is 1% of the smaller side of the viewport, while vmax is 1% of the larger side. On a portrait phone where width is the smaller side, 10vmin tracks the width and 10vmax tracks the height; rotate to landscape and the two swap, because the orientation changes which side is smaller. This makes vmin useful for elements that must stay fully visible in both orientations, such as a square that should never overflow, and vmax handy when you want something to scale with the dominant dimension. Regular vw and vh, by contrast, are locked to width and height specifically. This converter lets you enter your own viewport width and height, then shows how a value resolves in vw, vh, vmin, and vmax for that exact screen.
How do I make font sizes scale smoothly between screen sizes with clamp()?
The clamp() function takes three values, a minimum, a preferred, and a maximum, written as clamp(min, preferred, max). The browser uses the preferred value but never lets it drop below the minimum or rise above the maximum. For fluid typography, the preferred value combines a rem base with a vw term so the size grows linearly with viewport width between two breakpoints, then locks at the min on small screens and the max on large ones. This avoids text that jumps abruptly at each media-query breakpoint and instead scales continuously. Working out the slope and intercept by hand is fiddly, so this tool's clamp generator does it for you: enter a minimum and maximum size plus the viewport range you want the scaling to happen across, choose rem or px output, and copy the finished clamp() value straight into your stylesheet.
Embed This Tool
Add a free, live version of this widget to your own website or blog post — it runs entirely in your visitors' browsers, with a credit link back to The Toolbox.
<iframe src="https://getthetoolbox.com/embed/css-unit-converter" title="CSS Unit Converter — The Toolbox" width="100%" height="260" style="max-width:480px;border:1px solid #e2e8f0;border-radius:12px" loading="lazy"></iframe>
<p style="font-size:12px;margin:4px 0 0"><a href="https://getthetoolbox.com/utility-tools/css-unit-converter?utm_source=embed&utm_medium=widget" target="_blank" rel="noopener">Free CSS Unit Converter</a> by The Toolbox</p>Related Tools
Free Secure Password Generator
Generate secure, random passwords with customizable options. Free, fast, and works entirely in your browser with no sign-up required.
Free UUID/GUID Generator
Generate universally unique identifiers (UUIDs/GUIDs). Free, fast, and works entirely in your browser with no sign-up required.
Free QR Code Generator Online
Create QR codes for URLs, text, WiFi, and contacts. Customize colors, size, and error correction. Free, private — runs in your browser, no sign-up.
Free JSON Formatter & Validator
Format, validate, and beautify JSON data with syntax highlighting and error detection. Free, fast, and works entirely in your browser with no sign-up required.
About the CSS Unit Converter
The CSS Unit Converter turns a single length value into its equivalent across every CSS unit at once. Type a number, pick the unit you're starting from, and you instantly get the result in pixels plus 14 other units — rem, em, percentages, viewport units, points, and physical units — alongside the matching Tailwind CSS class where one exists. It's built for front-end developers, designers, and anyone translating a mockup into responsive stylesheet code without doing the arithmetic by hand.
Everything runs locally in your browser. There's no sign-up, no upload, and no server round-trip — values are computed on your device, so the tool works offline once the page has loaded and nothing you enter is stored or transmitted.
The 15 units it converts between
CSS units fall into three families, and the converter handles all of them, colour-coded by category:
- Absolute —
px,pt,pc,cm,mm,in. Fixed physical sizes. By the CSS reference standard, 1in = 96px = 72pt, so 1pt is roughly 1.333px, 1cm ≈ 37.8px, and 1pc = 16px. These matter most in print stylesheets. - Relative —
rem,em,%,ex,ch. Sized against something else. Aremis relative to the root<html>font-size (16px by default), anemis relative to the current element's font-size and compounds when nested, andchis the width of the "0" glyph — handy for capping text to ~60–75ch for readable line lengths. - Viewport —
vw,vh,vmin,vmax. Each is 1% of a viewport dimension;vmintracks the smaller side andvmaxthe larger, which keeps elements visible across portrait and landscape.
Because relative and viewport units depend on context, the converter lets you set the root and parent font-size, em nesting depth, viewport width and height, parent width, and ex/ch metrics — so the numbers reflect your actual layout rather than a generic assumption.
Why px-to-rem conversion is worth doing
The most common reason people open a converter like this is to move a design from fixed pixels to scalable rem units. When font sizes are set in rem, they respond to a visitor's browser font-size preference, which is an accessibility win that hard-coded pixels can't match. With a 16px root, 24px becomes 1.5rem and 12px becomes 0.75rem. The converter shows both at once and flags the equivalent Tailwind token (for example, 16px maps to text-base and spacing-4), so you can drop straight into a utility-class codebase.
Built-in scale and responsive generators
Beyond one-off conversions, the tool includes generators for systematic design work:
- Typography scale — build a modular type scale from a base size and a ratio such as Major Third (1.25), Perfect Fourth (1.333), or the Golden Ratio (1.618), with steps up and down and px/rem/em output.
- Spacing scale — generate a consistent spacing system on a chosen base grid (commonly 4px), output in px or rem.
- Breakpoint converter — translate any value and compare it against Tailwind's breakpoints (sm 640, md 768, lg 1024, xl 1280, 2xl 1536) and common device widths.
- Clamp generator — produce a fluid
clamp(min, preferred, max)value that scales linearly between two viewport widths, ideal for responsive typography that grows smoothly instead of jumping at each breakpoint.
A unit reference tab documents what each unit means with examples and usage tips, and a history panel keeps your recent conversions on hand. Every result has a one-click copy button so you can paste finished CSS straight into your stylesheet.