FIRST CH TOOLS / 21 PX ⇄ REM / EM
PX ⇄ REM / EM Converter & Font Size Scale
Set the root font size, then type into any of the px, rem or em boxes and the other two follow. The 12px–64px scale can be copied straight out as CSS custom properties or SCSS, and you can paste a whole stylesheet to convert px→rem in one go.
Set the base, then type into any box
Everything is calculated inside this page — nothing you type leaves the browser. Directly callable via URL parameters: /en/px-rem/?px=24 or /en/px-rem/?rem=1.5&root=10
The font sizes you actually use (12px–64px)
| px | rem | em | Typical use |
|---|
The table follows the root and parent font sizes you set on the “Convert” tab. With a 16px root, px ÷ 16 is the rem value and every size divides exactly — 16 is a power of two, so there is no binary rounding at all.
Paste a stylesheet and swap the units in bulk
Comments, strings (content: "10px") and the contents of url() are never rewritten, and neither are digits that are part of an identifier such as --size-16px.
How to Use
- Set the root font sizeUsually you can leave it at 16px, the browser default. If your stylesheet uses html { font-size: 62.5% }, press the 62.5% button to make the base 10px.
- Type into px, rem or emFill in any one box and the other two, the pt value and the CSS snippet update instantly. The “common values” buttons fill it in for you.
- Copy the scale or the whole stylesheetThe “Size scale” tab writes the 12px–64px table out as CSS custom properties or SCSS, and the “Bulk CSS” tab converts px→rem across a stylesheet you paste in.
About This Tool
rem is relative to the root (html) font size and em is relative to the parent font size. Browsers default to 16px, so unless you change it 1rem = 16px and the rem value is simply the px value divided by the base: 24px ÷ 16 = 1.5rem.
Sizes written in px ignore the reader's own font size setting. Someone who has set their default text size to 20px still gets 14px text from font-size: 14px. Written in rem, the same text scales with their setting, which is why font sizes, line heights and spacing are usually specified in rem. Page zoom does scale px as well, but the font size preference is a separate mechanism.
The 62.5% trick has a downside
html { font-size: 62.5% } makes the root 10px so that 1.4rem = 14px and the mental arithmetic disappears. It is a popular pattern, but every rem you write becomes 5/8 of the browser default, so a reader who has increased their font size gets less of an increase than they asked for. Leaving the root at 100% and converting the values here is the safer version.
Nested em values multiply
An element set to 0.9em inside another element set to 0.9em ends up at 0.81 of the outer size. That is why text shrinks step by step through nested lists or stacked components. Use rem for font sizes and em for spacing that should follow the element's own text (padding, margin, letter-spacing) and the problem goes away.
Values that do not divide exactly get rounded
With a 16px root every whole pixel divides exactly — 16 is 2⁴, so 13px = 0.8125rem is precise. Move the root to 14px or 15px and you get repeating values such as 16 ÷ 14 = 1.142857… that have to be cut off somewhere. This tool keeps up to six decimals, trims trailing zeros, and tells you underneath whether the value divided exactly. Browsers keep more precision internally, so three or four decimals is already beyond what anyone can see.
Keep 1px hairlines in px
Converted to rem, a hairline becomes 0.9px or 1.1px depending on the root size, so its thickness varies between devices and it can disappear entirely. Leave 1px borders in px. The “Leave 1px alone” option on the “Bulk CSS” tab skips any value that resolves to less than 2px.
Breakpoints belong in px
Breakpoints are usually about the device width, not about the root font size. Written in rem, a @media condition moves when the reader changes their font size setting. By default the conditions of @media and @container are left out of the conversion — the declarations inside the block are still converted.
pt is a print unit
In CSS 1pt is 1/72 inch and 1px is 1/96 inch, so 1px = 0.75pt. There is no reason to use pt for screen CSS, but print stylesheets and cross-checks against Word, PDF or design tools ask for points, so the value is shown alongside.
From AI Agents
This conversion is also available as the px_rem_convert tool of the MCP (Model Context Protocol) server @first-ch/tools-mcp, so an AI agent can call it directly without a browser — including passing the path of a stylesheet to convert and write out. See Using these tools from AI agents for setup.
Setup
claude mcp add firstch-tools -- npx -y @first-ch/tools-mcp
Examples
# how many rem is 24px (16px root)
px_rem_convert(value=24)
# 1.4rem in px with a 10px root
px_rem_convert(value=1.4, unit="rem", root=10)
# a whole stylesheet, px → rem (hairlines and @media conditions kept)
px_rem_convert(css="a{padding:24px;border:1px solid red}")
# read a file, convert it and write the result elsewhere
px_rem_convert(path="/tmp/style.css", outputPath="/tmp/style.rem.css", minPx=2)
Other Tools
- 01WebP Converter画像→WebP一括変換
- 02White BG Remover白背景の透過
- 03Contrast Checkerコントラスト比チェッカー
- 04Character Counter文字数カウント
- 05llms.txt Generatorllms.txt ジェネレーター
- 06JSON-LD GeneratorJSON-LD構造化データ生成
- 07Markdown → PDFMarkdown→PDF変換
- 08OGP Meta Tag WizardOGPメタタグ生成ウィザード
- 09Favicon Generatorfaviconジェネレーター
- 10TikTok PublisherTikTok投稿ツール
- 11Encoding Converter文字コード・改行コード変換
- 12AVIF Converter画像→AVIF変換+picture生成
- 13Test Data Generatorテストデータ生成
- 14Marp SlidesMarp Markdown→スライド
- 15Diff Checkerテキスト・コード差分チェッカー
- 16Cron ExplainerCron式ビジュアル解説&発火日時
- 17Base64 & Data URIBase64 & Data URI変換
- 18URL ParametersURLパラメータ分解・UTMタグ編集
- 19HTML EscapeHTMLエンティティ・特殊文字エスケープ
- 20JSON ⇄ YAMLJSON ⇄ YAML 相互変換
- 22Color Converter & AlphaColorコード変換&アルファ透過
- 23MD5 / SHA-256 Hash Generatorハッシュ生成
- 24JWT Decoder & Expiry CheckerJWTデコーダー&有効期限チェッカー
- 25User-Agent ParserUser-Agent解析&デバイス判定
- 26UUID & ULID GeneratorUUID (v4) & ULID 一括生成
- 27Aspect Ratio Calculatorアスペクト比計算&サイズ算出