px to rem converter
Convert px to rem and rem to px at whatever root font size your project uses — the 16px browser default, the 62.5% trick, or your own. Paste a whole stylesheet and every px length is rewritten in place while strings, comments and other units are left alone, then read the Tailwind v4 spacing and text scales in both units and copy what you need. No account needed.
The root is what html resolves font-size to — 16px unless a stylesheet changes it. Percent presets are relative to that 16px default: html { font-size: 62.5% } is a 10px root.
Convert one value
Type in either box; the other follows at the root size above. An em uses the parent's font size instead of the root, so the rem figure is also the em figure only where the parent inherits the root size.
Convert a CSS snippet
.card {
padding: 1rem 1.5rem;
margin: -0.5rem auto 0;
font-size: 0.875rem;
width: calc(100% - 2rem);
}
@media (min-width: 40rem) {
.card { padding: 2rem; }
}
/* Generated with Nodlume — https://nodlume.dev/px-to-rem */
Only lengths in the chosen unit change; strings, comments, url() arguments, custom-property names and every other unit stay exactly as pasted. Zero keeps its unit so a calc() stays valid.
Tailwind v4 reference
The named multiples of --spacing (0.25rem) that p-*, m-*, gap-*, w-* and friends accept. The rem column is fixed by Tailwind; the px column is what it renders to at your root size.
| Step | rem | px at 16px root |
|---|---|---|
px | — | 1px |
0 | 0rem | 0px |
0.5 | 0.125rem | 2px |
1 | 0.25rem | 4px |
1.5 | 0.375rem | 6px |
2 | 0.5rem | 8px |
2.5 | 0.625rem | 10px |
3 | 0.75rem | 12px |
3.5 | 0.875rem | 14px |
4 | 1rem | 16px |
5 | 1.25rem | 20px |
6 | 1.5rem | 24px |
7 | 1.75rem | 28px |
8 | 2rem | 32px |
9 | 2.25rem | 36px |
10 | 2.5rem | 40px |
11 | 2.75rem | 44px |
12 | 3rem | 48px |
14 | 3.5rem | 56px |
16 | 4rem | 64px |
20 | 5rem | 80px |
24 | 6rem | 96px |
28 | 7rem | 112px |
32 | 8rem | 128px |
36 | 9rem | 144px |
40 | 10rem | 160px |
44 | 11rem | 176px |
48 | 12rem | 192px |
52 | 13rem | 208px |
56 | 14rem | 224px |
60 | 15rem | 240px |
64 | 16rem | 256px |
72 | 18rem | 288px |
80 | 20rem | 320px |
96 | 24rem | 384px |
Any root, not just 16
Most px to rem converters assume a 16px root. This one takes the root as an input, with one-click presets for the browser default and the 62.5% shortcut, so the numbers match the stylesheet you actually ship.
Whole snippets, not one number
Paste a rule, a file or a media query. A real tokenizer rewrites only the lengths in the unit you chose — custom-property names, hex colors, url() paths and content strings come back untouched.
Tailwind v4 scales in both units
The named --spacing steps and the default --text-* sizes, each in rem and in px at your root — copy the table as Markdown for a design doc.
px, rem and em, answered
- What is rem in CSS?
- rem is "root em": a length relative to the font size of the root element, the <html> tag. With the browser default of 16px, 1rem is 16px, 0.5rem is 8px and 1.5rem is 24px. Because every rem on the page refers to the same root, a visitor who raises their browser's default font size scales every rem-based measurement at once — which is the point of using it.
- What is the difference between rem and em?
- An em is relative to the font size of the element it is used on (or, for font-size itself, of the parent), so ems compound: 1.2em inside 1.2em is 1.44 times the outer size. A rem always refers to the root, so it never compounds. Use rem for sizes that should be consistent across the page, and em for things that should scale with their own text, like an icon's width or a button's padding.
- Why is 16px the default root font size?
- Every major browser ships with a default font size of 16px for normal text, and the root element inherits it unless a stylesheet overrides it. That is why px to rem math divides by 16 unless you set a different root — and why this converter lets you change the root instead of assuming it.
- Should I use rem for everything?
- Use rem for font sizes, spacing, container widths and media queries — anything that should grow when the visitor asks for larger text. Keep px for things that must not scale: 1px borders and hairlines, box-shadow offsets, and image dimensions. Line heights are best left unitless. Tailwind follows this split: its spacing and text scales are rem, while border widths stay px.
- What does html { font-size: 62.5% } do?
- It sets the root to 62.5% of the browser default — 10px at 16px — so 1rem becomes a round 10px and 1.6rem is 16px. The arithmetic is easier, but the trick also shrinks the base size the visitor chose by 37.5%, so every element must then be sized back up explicitly. Many teams prefer the plain 16px root; this converter supports both so you can compare.
- How do I convert px to rem in Tailwind?
- Tailwind v4 defines its scales in rem: --spacing is 0.25rem, so p-4 is 1rem (16px at the default root), and text-sm is 0.875rem (14px). For a size that is not on the scale, use an arbitrary value such as p-[18px] or, better, p-[1.125rem], which is what the converter gives you. The reference table on this page shows every named step in both units at your root size.
- Does this tool send my CSS anywhere?
- No. Every conversion runs in your browser; nothing you type or paste is sent to Nodlume or any other server, and nothing is stored once you leave the page.
One unit is a decision, a scale is a system
Rem is the unit; the sizes you put in it are the design. Build the type sizes with the modular scale calculator, which emits its --text-* tokens in rem, and turn colors, fonts, radius, shadows and spacing into one Tailwind v4 stylesheet in the theme generator. Then design the whole app on a visual canvas and export a real Next.js project with the tokens already wired in.