Typography Unit Converter
Convert typography units: pt, px, em, rem, pica and more with DPI settings.
| Unit | Converted Value |
|---|---|
| px | 16 |
| pt | 12 |
| em | 1 |
| rem | 1 |
| pica | 1 |
| mm | 4.2333 |
| cm | 0.42333 |
| in | 0.16667 |
| ex | 2 |
| ch | 2 |
Common Reference Values
About this tool
Typography units are the backbone of digital and print design, but converting between them—points, pixels, ems, rems, picas, and more—can be tedious and error-prone. Whether you're a designer translating print specifications to web designs, a developer adjusting font sizes across different rendering contexts, or a content creator managing documents across platforms, precision matters. This converter eliminates the guesswork by instantly translating any typography unit into any other, while accounting for DPI settings that significantly affect pixel-to-point conversions.
To use the tool, simply select your source and target units from the dropdowns, enter the value you want to convert, and optionally adjust the DPI setting if you're working with specific output media. The converter handles relative units like em and rem, which scale based on parent or root font sizes, as well as absolute units like points and pixels. For example, converting 16 pixels to rem assumes a 16px base, resulting in 1rem—useful when building responsive web designs that scale gracefully across devices.
Frequently Asked Questions
Code Implementation
def typography_converter(value: float, from_unit: str, to_unit: str,
dpi: float = 96, base_font_px: float = 16) -> float:
"""Convert between typography units. Returns converted value."""
# Convert to px first
to_px = {
'px': lambda v: v,
'pt': lambda v: v * dpi / 72,
'pc': lambda v: v * dpi / 6,
'em': lambda v: v * base_font_px,
'rem': lambda v: v * base_font_px,
'mm': lambda v: v * dpi / 25.4,
'cm': lambda v: v * dpi / 2.54,
'in': lambda v: v * dpi,
'ex': lambda v: v * base_font_px * 0.5,
'ch': lambda v: v * base_font_px * 0.5,
}
from_px = {
'px': lambda v: v,
'pt': lambda v: v * 72 / dpi,
'pc': lambda v: v * 6 / dpi,
'em': lambda v: v / base_font_px,
'rem': lambda v: v / base_font_px,
'mm': lambda v: v * 25.4 / dpi,
'cm': lambda v: v * 2.54 / dpi,
'in': lambda v: v / dpi,
'ex': lambda v: v / (base_font_px * 0.5),
'ch': lambda v: v / (base_font_px * 0.5),
}
px = to_px[from_unit](value)
return from_px[to_unit](px)
# Examples
print(f"16px = {typography_converter(16, 'px', 'pt'):.4f}pt at 96dpi")
print(f"1em = {typography_converter(1, 'em', 'px'):.4f}px at base 16px")
print(f"12pt = {typography_converter(12, 'pt', 'px'):.4f}px at 96dpi")
print(f"1in = {typography_converter(1, 'in', 'pt'):.4f}pt")
Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.