PX to EM Calculator
Convert between px and em using the parent element font-size as the basis. An em is relative to the current element's font-size, so the parent value is what 1em equals here. The default basis is 16px.
How to convert px to em
- Pick a direction: px to em, or em to px.
- Set the parent font-size that 1em should equal in this context.
- Type your value and copy the converted result.
Examples
Convert a pixel size to em
24px at a 16px parent
1.5em
Convert em back to pixels
0.5em at a 20px parent
10px
Frequently asked questions
What is the difference between em and rem?
An em is relative to the font-size of the parent or current element, while a rem is relative to the root font-size on the html element. Because em depends on the parent, the same em value can resolve to different pixel sizes in different parts of a page.
How do I convert px to em?
Divide the pixel value by the parent font-size. With a 16px parent, 24px is 24 divided by 16, which is 1.5em. To go the other way, multiply the em value by the parent font-size.
Why does em compound when elements are nested?
Each em resolves against its own parent. If a parent is set to 1.2em it grows, and a child set to 1.2em multiplies on top of that, so sizes can snowball through nested elements. Rem avoids this by always using the root.
What parent font-size should I use?
Use the computed font-size of the element that the em value applies to, which is usually inherited from its parent. If you are unsure, 16px is the common browser default and a safe starting point.
When should I prefer em over rem?
Em is handy for spacing that should scale with a component's own font-size, such as padding inside a button that grows with its label. Rem is better when you want sizing to stay consistent across the whole page.
Related tools
PX to REM Calculator
Convert px to rem and rem to px with any root font-size. Set the root, type a value, and copy the result for clean, scalable CSS typography.
Line Height Calculator
Calculate a unitless CSS line-height from a font size and a pixel line height, or work out the pixel height from a ratio. Fast, exact, and private.
Letter Spacing Calculator
Convert Photoshop or Figma tracking to CSS letter-spacing in em and px. Tracking is in thousandths of an em, so 50 becomes 0.05em. Exact and free.
.env to JSON
Convert a .env file to JSON, or JSON back to .env. Parses KEY=value lines, comments, quotes and export. Runs entirely in your browser.
ASCII Table
Full ASCII table for all 128 codes with decimal, hex, octal and binary values, character names and descriptions. Search by code, hex or character.
Aspect Ratio Box Generator
Generate CSS for a responsive aspect-ratio container. Use the modern aspect-ratio property or the padding-top fallback, then copy the ready code.