CSS values and design tokens
PX to REM Converter
Convert one value or a whole spacing and typography scale. Set your root font size, see exactly what rounding changes, and export ready-to-use CSS custom properties.
Set up your conversion
The interactive converter requires JavaScript and a browser with BigInt support.
Converted values
| Token | Input | Result | Precision | Pixel difference |
|---|
CSS uses --size- names. For example, use font-size: var(--size-body); for a named body token. Review values and CSS property rules before use. CSV includes units and the base; signed cells start with an apostrophe to keep spreadsheet imports as text. Some CSV readers display that apostrophe. Values-only output omits base and precision context.
How to use the converter
- Choose a conversion direction and enter the root font size for your layout.
- Paste a single number, a list, or named values. Choose the number of decimal places and select Convert values.
- Check the Exact or Rounded status and pixel difference, then copy or download the format you need. Editing an input clears the previous result.
Precision you can inspect
Input decimals are parsed exactly and calculated with integer arithmetic before rounding once. For example, 1px ÷ 3px becomes 0.3333rem at four decimal places. At that base, the displayed result represents 0.9999px, a difference of -0.0001px. Exact means no arithmetic rounding at the chosen precision; it does not describe browser rasterization.
Halfway values round away from zero: at a 16px base and two decimal places, 2px becomes 0.13rem and -2px becomes -0.13rem. Small nonzero inputs may round to zero. The table flags those cases. Negative numbers can be useful for margins or offsets, but many CSS properties, including font-size and padding, reject negative lengths.
When the root assumption needs care
For ordinary element styles, rem uses the root element's font size. CSS pixels are reference units and do not necessarily equal hardware pixels. A root of 62.5% equals 10px only when the size it resolves against is 16px; at 20px it equals 12.5px.
Do not use a computed html size to automatically rewrite media-query breakpoints or the root's own font-size declaration. Font-relative media-query units use initial font values; rem in the root's own font-size also has an initial-font rule. Those contexts need their own base. This tool does not process selectors, declarations, comments, quoted strings, URLs, custom-property references or calc() expressions.
REM and accessibility
Relative sizing can help a layout respond to font settings when the root sizing allows it. Using rem alone does not ensure accessibility, and pixel-based text can still scale with browser zoom. Test your actual page at increased text sizes and 200% zoom for lost content or controls.
Privacy and standards
The converter runs locally in your browser. It does not send values to a server or save them in cookies or browser storage. Copy uses your browser's clipboard capability; downloads are generated locally. The site's shared analytics are separate from this converter.
Definitions and context: CSS font-relative units, CSS absolute lengths, media-query units and W3C guidance on resizing text.