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.

Presets

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

7 lengths converted
.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.

Steprempx at 16px root
px—1px
00rem0px
0.50.125rem2px
10.25rem4px
1.50.375rem6px
20.5rem8px
2.50.625rem10px
30.75rem12px
3.50.875rem14px
41rem16px
51.25rem20px
61.5rem24px
71.75rem28px
82rem32px
92.25rem36px
102.5rem40px
112.75rem44px
123rem48px
143.5rem56px
164rem64px
205rem80px
246rem96px
287rem112px
328rem128px
369rem144px
4010rem160px
4411rem176px
4812rem192px
5213rem208px
5614rem224px
6015rem240px
6416rem256px
7218rem288px
8020rem320px
9624rem384px

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.

We'd like to use Google and Microsoft Clarity cookies to understand how Nodlume is used (including masked session replays) and to measure our advertising. Optional cookies only load if you accept, and declining does not affect anything in the app.