Home › Developer Tools › PX to EM Converter

PX to EM Converter

Convert pixel values to em units relative to the parent element's font size, or em back to pixels. Paste a whole list of values, see the matching percentage and rem, and work out the real parent size when ems are nested.

Last updated:

Direction

One value, or several separated by commas or spaces.

px

The font-size of the parent element (16px browser default).

Each em size compounds: 16px × 1.25 × 0.875 = 17.5px parent.

Enter your values to see the result.
Advertisement
Advertisement

How to use the PX to EM Converter

  1. Pick the direction: PX → EM or EM → PX.
  2. Enter one value or a list such as 12, 14, 18, 24.
  3. Set the parent font size in px (16px if the parent uses the browser default).
  4. If the parent itself is sized in em, tick the nesting box and list the ancestor em values.
  5. Copy the result or download the tables as CSV.

PX to EM formula

em = px ÷ parent font size and px = em × parent font size. When ems are nested, the parent font size is itself the product of the root size and every ancestor's em value: 16px × 1.25 × 0.875 = 17.5px.

PX to EM at a 16px base

pxempxempxem
8px0.5em16px1em28px1.75em
10px0.625em18px1.125em32px2em
12px0.75em20px1.25em36px2.25em
13px0.8125em22px1.375em40px2.5em
14px0.875em24px1.5em48px3em
15px0.9375em26px1.625em64px4em

When to use em

  • Component spacing: padding and margins in em grow with the component's own text, so a button stays proportional at any font size.
  • Media queries: em-based breakpoints (e.g. @media (min-width: 48em)) follow the user's default font size.
  • Avoid deep nesting for font sizes: use rem when you want a predictable size anywhere on the page.

Frequently asked questions

How do I convert px to em?

Divide the pixel value by the parent element's font size: em = px ÷ parent font size. With the default 16px, 24px = 24 ÷ 16 = 1.5em.

How do I convert em to px?

Multiply: px = em × parent font size. For example 0.875em inside a 16px parent is 14px.

What is the difference between em and rem?

em is relative to the font size of the element's parent (for font-size) or the element itself (for other properties like padding), so it compounds when nested. rem is always relative to the root html element's font size, so 1rem is the same everywhere on the page.

Why do nested em values compound?

Each em font size is calculated from its parent, so a 1.25em list inside a 1.25em container is 1.25 × 1.25 = 1.5625 times the root size. Tick the nesting option to calculate the real parent size from a chain of ancestor em values.

What is 1em in px?

1em equals the computed font size of the parent element. In a browser with default settings and no CSS changes, that is 16px.

Is em relative to the parent for padding and margin?

No. For properties other than font-size, em is relative to the element's own computed font size. If an element has font-size: 20px, then padding: 1em is 20px.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

PX to REM ConverterConvert px to rem or em and back, with a 1-100px table and a whole-CSS converter.PX to VW ConverterConvert pixels to vw and vh for any viewport size, and vw/vh back to px, with breakpoint tables.CSS Clamp GeneratorTurn min/max sizes and viewport widths into a fluid CSS clamp() value in rem and vw.PX to PTConvert pixels to points (px to pt) instantly, with formula and chart.Font Size ConverterConvert font sizes between px, pt, em, rem, % and vw, with a 6–72px chart and CSS.JSON to Excel ConverterTurn JSON into a styled .xlsx spreadsheet; nested arrays become their own linked sheets.JSON to CSVConvert JSON data to CSV for spreadsheets.CSV to JSONConvert CSV data to JSON with live preview.Excel to CSVConvert XLSX spreadsheets to CSV.CSV ViewerOpen a CSV or TSV file as a sortable, filterable table.Excel Viewer (XLSX / XLS)Open XLSX, XLS and ODS spreadsheets in your browser without Excel.Line Ending ConverterConvert text and files between CRLF, LF and CR line endings.Markdown to HTMLConvert Markdown to clean HTML with a live editor.XML to JSONConvert XML to JSON with validation.Text Encoding ConverterDetect and convert text file encodings like UTF-8, UTF-16 and Latin-1.JSON ViewerExplore JSON as a collapsible tree, search keys and values and copy any node's path.TTF to WOFF2 ConverterConvert TTF and OTF fonts to WOFF2 or WOFF and get a ready @font-face CSS snippet.Chmod CalculatorConvert Linux file permissions between checkboxes, octal (755) and symbolic (rwxr-xr-x) notation.JSON to TypeScriptGenerate TypeScript interfaces or types from JSON, with nested types and optional fields.Morse Code TranslatorTranslate text to Morse code and back, then play it as sound or a blinking light, or save a WAV.HTML Table GeneratorBuild HTML tables in an editable grid with styles, header rows, CSV import and live preview.Hex to Text ConverterConvert hex to text and text to hex with UTF-8 support and space, 0x, \x or comma formats.JSON to XML ConverterConvert JSON to well-formed XML with attributes, arrays and pretty print.JSON to YAML ConverterConvert JSON to clean YAML as you type, with indent, quoting and sort options.YAML to JSON ConverterConvert YAML to pretty or minified JSON, with errors pinned to the exact line.HTML to Markdown ConverterTurn HTML or pasted rich text into clean Markdown with tables and live preview.Markdown Table GeneratorBuild Markdown tables in a grid or paste from Excel/CSV, with alignment and preview.JSON ValidatorCheck JSON with the exact line and column of each error, fix tips and one-click auto-fix.Image to Base64Convert images to Base64 data URIs, CSS backgrounds and HTML img tags in your browser.Base64 to ImagePaste a Base64 string or data URI to preview, identify and download the image.JSON CompareCompare two JSON documents and see every added, removed and changed path.Hex to DecimalConvert hex to decimal instantly with steps and signed mode.Decimal to HexConvert decimal to hex instantly with steps and signed mode.Binary to DecimalConvert binary to decimal instantly with steps and signed mode.Decimal to BinaryConvert decimal to binary instantly with steps and signed mode.Two's Complement CalculatorDecimal to two's complement binary and back for 4-64 bits, with invert-and-add-1 steps.XML to CSV ConverterConvert XML to CSV: detects repeating records, flattens nested data, pick your columns.CSV to XML ConverterConvert CSV to well-formed XML with custom root and row names, escaping and pretty print.Remove Duplicates in ExcelFind and remove or highlight duplicate rows in XLSX or CSV files by the columns you choose.GeoJSON ViewerView GeoJSON on a map, inspect and edit properties, validate against RFC 7946 and export.GPX ViewerOpen GPX tracks on a map with distance, elevation profile, moving time, speed and splits.JSON Repair ToolFix broken JSON automatically: trailing commas, quotes, comments, truncated data, with a diff.Karnaugh Map SolverSolve 2–6 variable K-maps: click cells or enter minterms to get the minimal SOP or POS with groups.Merge Excel FilesCombine XLSX, XLS and CSV files into one workbook or append all rows into a single sheet.Parquet File ViewerOpen Apache Parquet files in your browser: schema, rows, filters and CSV or JSON export.Query CSV with SQLRun SQL on CSV, Excel, JSON and Parquet files in your browser with DuckDB. Join and export.Online Serial MonitorTalk to Arduino, ESP32 and USB serial devices in your browser: log, send, plot and save.Split Excel FileSplit an Excel sheet into several files by row count or by each value in a column, as ZIP.SQL Create Table GeneratorDefine columns, keys, defaults and indexes; get CREATE TABLE SQL for MySQL, Postgres and more.SQL IN Clause GeneratorTurn a pasted list into a SQL IN ('a','b') clause with quoting, dedupe and 1,000-item chunks.SQL Online CompilerRun SQL queries online on SQLite with sample databases, a result grid, CSV export and .db save.SQL to ER DiagramPaste CREATE TABLE statements and get an entity-relationship diagram with keys and links.XML to XSD GeneratorGenerate an XML Schema (XSD) from sample XML: types, occurrences, attributes and namespaces.XML ValidatorCheck if XML is well-formed, see the exact line and column of each error and pretty-print it.Wildcard Mask CalculatorConvert a subnet mask or CIDR to a wildcard mask for ACLs and OSPF, with range and binary.CSV to VCF ConverterConvert a contacts CSV into a vCard (.vcf) file, mapping columns to name, phone, email and more.CSV to YAML ConverterConvert CSV rows to a YAML list of mappings with type inference and delimiter detection.Endianness ConverterSwap byte order of 16, 32 and 64-bit hex values and see big- and little-endian integers and floats.Excel to SQL ConverterTurn an Excel sheet into CREATE TABLE and INSERT statements for MySQL, PostgreSQL, SQLite or SQL Server.Excel to VCF ConverterTurn an Excel contact list into a vCard .vcf file for iPhone, Android, Google or Outlook.File to C ArrayConvert any file into a C or C++ byte array header, like xxd -i, with const and PROGMEM options.Image to C ArrayConvert images to monochrome, RGB565 or RGB888 C arrays for OLED, LCD and TFT displays.JSON Merge ToolDeep-merge two or more JSON objects with array concat, replace or union and a conflict rule.JSONL to CSV ConverterConvert JSON Lines / NDJSON to CSV with flattened columns; streams large files locally.PHP Unserialize OnlineDecode PHP serialize() strings to JSON, a tree or print_r, and serialize JSON back to PHP.SQL Dialect ConverterTranslate SQL between MySQL, PostgreSQL, SQLite, SQL Server, Oracle, BigQuery and more.TSV to JSON ConverterTurn tab-separated data pasted from Excel or Sheets into a JSON array or keyed object.XLS to XLSX ConverterConvert old Excel 97-2003 .xls workbooks to modern .xlsx files in your browser, several at once.
See all 129 Data & File Format Converters →