px to em Converterv1.0.0
Bidirectional px to em conversion against a configurable base font size (default 16 pixels), accepting decimals, fractions, and mixed numbers. The body value also seeds a typographic hierarchy across 8 modular scale ratios (Minor Second 1.067 through Golden Ratio 1.618) with Display, H1 through H6, body, caption, and micro sizes in px, em, and rem plus suggested line-heights, and a complementary spacing scale with 4xs through 4xl tokens.
Documentation
Convert between pixel and em units quickly with this bidirectional CSS unit converter. Enter a value in pixels to get the equivalent em value, or switch the direction to convert em back to pixels. Adjust the base font size to match your project root font size for accurate results. Accept flexible input formats including decimals, fractions, and mixed numbers.
- Select the conversion direction using the px to em or em to px radio buttons at the top of the tool.
- Enter the numeric value you want to convert in the Value field. Type decimals like 14.5, fractions like 3/4, or mixed numbers like 1 1/2.
- Set the Base Font Size (px) to match your project root font size. Most browsers default to 16px.
- Watch the result update automatically as you type, or click the Convert button to trigger the calculation manually.
- Open the Settings panel and check Show step-by-step formula to see the full derivation of each conversion.
- Reference the quick conversion table for common pixel to em mappings at the default 16px base size.
- Apply the formula em equals pixels divided by base font size for px to em, or pixels equals em multiplied by base font size for em to px.
- Use the Typographic Hierarchy section to see a complete heading scale derived from your current value as body text. Choose a modular scale ratio from subtle Minor Second to dramatic Golden Ratio to control how much each heading level jumps in size.
- Read the Suggested line-height column to pair each heading and body size with a complementary line height that keeps long passages readable and headlines tight.
- Apply the Complementary Spacing Scale tokens, named 4xs through 4xl, to margins, padding, and gap values so spacing stays proportional to the typography.
Pixel to em conversion is essential for building responsive, accessible web interfaces. Em units scale relative to the parent font size, making them a powerful foundation for fluid typography and layout systems. Designers and developers benefit from confident work with relative CSS units alongside complementary type and spacing scales.
- Web Development: Convert a design mockup specifying 14px body text and 24px headings into em values for a stylesheet with a 16px root font size. Enter 14 and 24 to receive 0.875em and 1.5em respectively.
- Responsive Design: Calculate em-based media query breakpoints from pixel values. Convert 768px and 1024px viewport widths to em for use in CSS media queries that respect user font size preferences.
- Accessibility: Ensure text scales properly for users who increase their browser default font size. Convert fixed pixel sizes to em to support relative scaling across the entire interface.
- Design Systems: Generate a full typography scale by entering a body size and selecting a modular ratio. Use the Typographic Hierarchy table to grab Display, H1 through H6, body, caption, and micro sizes in px, em, and rem for design tokens.
- Type Scale Selection: Compare how different modular ratios feel by switching between Minor Third, Major Third, Perfect Fourth, and Golden Ratio scales. See exactly which H1 through H6 sizes result from your body text choice and pick the ratio that matches your brand voice, from subtle for editorial sites to dramatic for marketing pages.
- Spacing Systems: Derive a harmonious spacing scale from the same body size that drives your type. Apply the 4xs through 4xl tokens to margins, padding, and gap values so every layout decision stays proportional to the typography.
- Email Development: Translate pixel-based email designs into em units for better rendering across email clients that override base font sizes.
- Education: Learn how relative CSS units work by experimenting with different base font sizes and observing how the em value changes. Toggle the step-by-step formula display to understand the math behind each conversion.
- Legacy Code Migration: Refactor older stylesheets that use fixed pixel values into modern em-based layouts. Enter each pixel value to determine the correct em replacement for a given base size.
Inputs, outputs, and what the px to em Converter computes
The form above accepts the following inputs and produces the outputs listed below. This summary is rendered in the page so the parameters are visible to crawlers, assistive tech, and indexing agents that don't fetch the embedded tool frame.
Inputs
- px to em · default: px-to-em
- em to px · default: em-to-px
- Value (text input) · default: 16
- Base Font Size (px) (text input) · default: 16
- Show step-by-step formula · default: 1
- Type Scale · default: Minor Third (1.2) - balanced
Controls
Convert · Reset
Worked example
Convert between pixel and em units quickly with this bidirectional CSS unit converter.