Skip to content

Menu

CSS Unit Converter

Convert between CSS units

Runs entirely in your browserFrontendFree, no sign-up
Loading tool

01What is CSS Unit Converter?

Design files speak pixels, browsers respect user font settings, and print stylesheets want millimetres. This converter sits between them. Type a Value, pick a From unit and a To unit, and you get the Result plus an All Conversions grid showing the same length in all ten units: px, rem, em, vw, vh, %, pt, cm, mm and in. Under the hood every conversion goes through pixels. The absolute units follow the CSS Values and Units spec, where 1in equals 96px. That makes 1pt 96/72 px, 1cm 96/2.54 px and 1mm 96/25.4 px. So 12pt is exactly 16px, and an A4 width of 210mm comes out as 793.7008px. Relative units need context, and this is where most converters quietly guess. rem always uses the root font size. vw and vh are hundredths of the viewport width and height. But % and em change meaning with the property, so you choose one from the Property list and the tool prints the basis it's using right under it. The rules come from the CSS specs, summarised on MDN. For font-size, both % and em resolve against the parent's font size. For line-height, they use the element's own font size. For width, left and right, and padding or margin on any side, % is a share of the containing block's width. Yes, that includes padding-top. For height, top and bottom, % uses the containing block's height. Outside font-size, 1em is the element's own font size. Worked example: you're converting 150% for font-size with Parent font set to 20. The tool resolves 150% of 20px and shows 30px. Switch the Property to width and the same 150% becomes 1800px, because the basis is now the 1200px containing block. Context Settings holds the numbers. Defaults are 16px for root, parent and element fonts, a 1920 by 1080 viewport and a 1200 by 800 containing block. Clearing a context field puts its default back. Results round to four decimal places with trailing zeros trimmed, and anything under 0.001 shows as 0. Copy puts the number and unit on your clipboard, like 1.5rem. Reset returns to 16px to rem with the width property. There are limits. The tool can't see your real layout, so the answer is only as right as the context you enter. It also handles one em level, not compounding through nested elements. Everything is plain arithmetic in your tab, so your numbers stay local.

Front-end developers and people writing print stylesheets use it to translate one CSS length into another with the right context. The tool runs entirely in your browser, so your data never leaves your device.

02How to use CSS Unit Converter

  1. Type a number into Value
  2. Choose the From and To units
  3. For % or em, pick the Property so the right basis is used, and read the basis line under it
  4. Open Context Settings and set Root font, Parent font, Element font, Viewport W and H, and Containing block W and H
  5. Read the Result and scan the All Conversions grid
  6. Click Copy to grab the value with its unit

03Worked examples

Input: 24px to rem (Root font 16)
Result: 1.5rem
Input: 1.5rem to px (Root font 10)
Result: 15px
rem follows the root font size, not the parent's.
Input: 50% to px, Property: width (Containing block W 1200)
Result: 600px
Input: 50% to px, Property: height (Containing block H 800)
Result: 400px
Same 50%, different answer, because height percentages use the containing block's height.
Input: 150% to px, Property: font-size (Parent font 20)
Result: 30px
Input: 1.5em to px, Property: line-height (Element font 18)
Result: 27px
For line-height, em uses the element's own font size.

04Common use cases

  • Turning a 24px heading from a Figma spec into rem for a stylesheet that honours user font settings
  • Checking how wide 50vw is on a 1366 px laptop before you ship a hero section
  • Translating A4 margins in mm into px or in for a printable invoice page
  • Working out what 1.5em line-height means for an 18px paragraph
  • Showing a teammate why padding-top: 50% follows the containing block width, not its height
  • Converting a 10pt print font size from a brand guide into CSS pixels

05Tips

  • Browsers default to a 16px root font, but users can raise it. rem follows that preference and px ignores it.
  • em compounds when nested: a 1.2em font inside another 1.2em font ends up 1.44 times the base, and this tool only computes one level.
  • CSS inches and centimetres are tied to 96px, so they won't match a physical ruler on most screens. They do map well to print.
  • padding-top: 56.25% gives a 16:9 box because vertical padding percentages use the containing block's width.
  • A percentage height only resolves when the containing block has a definite height. Otherwise the browser treats it as auto.

06Related concepts

rem, em, viewport units, CSS reference pixel, responsive typography.

Frequently Asked Questions

What is CSS Unit Converter?

CSS Unit Converter is a free, browser-based developer tool on AIDToolStack. Convert between CSS units It requires no installation or sign-up and works entirely in your browser.

Is CSS Unit Converter free to use?

Yes. No sign-up, no fees and no usage cap.

Does CSS Unit Converter store my data?

No. It runs in your browser; nothing is uploaded.

Cheat sheet

Reviews and commentsShow

Reviews

Sign in to leave a review.

Loading reviews…

Comments

Sign in to leave a comment.

Loading comments…

What changed in AI dev tools, once a month

Renames, shutdowns, pricing changes and new MCP setups, each with a source.

Subscribe