Works on this device
Typography Calculator
Do the sums of type setting in one place. Convert a font size between units, build a type scale from a ratio, and work out line height, line length, letter spacing and a fluid font size. Each answer also comes as a line of CSS where that helps.
Enter your values
Check these values
Your values are worked out in this browser. They are not sent to a server.
Your result will show here
Fill in the values, then choose Calculate.
Your result
How it was worked out
How to use this calculator
- Choose what you want to work out, for example Convert a font size between units.
- Enter the values you know. Fields under More options have sensible starting values that you can change.
- Choose Calculate. The answer shows as numbers, and often as a table and a line of CSS.
- Choose Copy text to copy the CSS, or download the result as a CSS or CSV file.
The units and formulas
- Absolute units. CSS fixes these: 1 inch = 96 px = 72 pt = 6 pc = 2.54 cm. So 1 pt = 4/3 px, and 1 px = 0.75 pt. A CSS pixel is a reference unit. It is not always one dot of a screen or a printer.
- Relative units. 1 rem is the font size of the page, called the root font size. 1 em and 100% are the font size of the parent element. Most browsers start with a root font size of 16 px.
- Type scale. Size of step n = base size × ratio to the power n. Step 0 is the base size, and steps below it use negative numbers.
- Line height. Line height = font size × the line height number. The space added between lines is the line height minus the font size. Half of it goes above each line and half below.
- Line length. Characters per line = line width ÷ (width of an average character in em × font size).
- Fluid font size. Slope = (large size − small size) ÷ (large width − small width). Intercept = small size − slope × small width. The CSS is
clamp(small size, intercept + slope × 100vw, large size). - Vertical rhythm. Each line height is a whole number of grid steps. The tool picks the smallest number of steps that gives at least the smallest line height you allow.
- Letter spacing. Letter spacing in em = tracking ÷ 1000. Many layout programs give tracking in thousandths of an em.
- Fall-back font. size-adjust = (web font average width ÷ its units per em) ÷ (fall-back average width ÷ its units per em). Each of ascent-override, descent-override and line-gap-override = the web font value ÷ (units per em × size-adjust).
Named ratios for a type scale
These are plain number ratios with names taken from music. The menu Named ratios fills them in for you. You can also type any ratio above 1, as a decimal or as a fraction such as 4/3.
| Name | Ratio | Value |
|---|---|---|
| Minor second | 16:15 | 1.0667 (rounded) |
| Major second | 9:8 | 1.125 |
| Minor third | 6:5 | 1.2 |
| Major third | 5:4 | 1.25 |
| Perfect fourth | 4:3 | 1.3333 (rounded) |
| Augmented fourth | square root of 2 | 1.4142 (rounded) |
| Perfect fifth | 3:2 | 1.5 |
| Minor sixth | 8:5 | 1.6 |
| Golden ratio | (1 + square root of 5) ÷ 2 | 1.6180 (rounded) |
| Major sixth | 5:3 | 1.6667 (rounded) |
| Minor seventh | 16:9 | 1.7778 (rounded) |
| Major seventh | 15:8 | 1.875 |
| Octave | 2:1 | 2 |
Worked examples
Units. 12 pt × 96 ÷ 72 = 16 px. With a root font size of 16 px that is 1 rem, 1 em and 100%. It is also 4.23333 mm and 0.166667 inches.
Type scale. With a base of 16 px and a ratio of 1.25, step 1 is 20 px, step 2 is 25 px and step 3 is 31.25 px. Step −1 is 12.8 px. In rem these are 1.25, 1.5625, 1.9531 and 0.8.
Line height. A 16 px font with a line height of 1.5 has lines 24 px apart. The added space is 8 px: 4 px above and 4 px below each line.
Line length. A column 640 px wide with a 16 px font and an average character of 0.5 em holds about 640 ÷ (0.5 × 16) = 80 characters per line.
Fluid font size. From 16 px at a width of 320 px to 24 px at 1280 px: slope = 8 ÷ 960, which is 0.8333vw. Intercept = 16 − 320 × 8 ÷ 960 = 13.3333 px, which is 0.8333 rem. The CSS is font-size: clamp(1rem, 0.8333rem + 0.8333vw, 1.5rem);. At a width of 800 px the font size is 20 px.
Letter spacing. A tracking of 50 is 0.05 em. At a font size of 16 px that is 0.8 px.
Limits you should know
- The line length is an estimate from a rule of thumb: an average character is taken as half an em wide. Fonts differ, so change that number to fit your font. To measure real text in a real font, use the Font Inspector & Previewer.
- Guidance such as 45 to 75 characters per line, or a line height near 1.5 for body text, is advice from type setting practice. It is not a rule, and this tool does not judge your design.
- Numbers in the CSS text are rounded: 4 decimal places for rem, em and vw, and 2 for px and percent. The tables show the sizes before that rounding.
- A fluid rule that uses vw does not grow when a reader zooms the page. Test that your text can still be made 200% larger.
- The fall-back font numbers are only as good as the font metrics you enter. This tool does not read font files. The average character width in a font file is one number for all characters, so the match for your own text is close, not exact.
- A baseline grid sets line heights. A browser still places each font inside its line by the metrics of that font, so the baselines of two different fonts can sit a little apart.
- Print sizes use the CSS inch of 96 px. A real printer or screen may show a different physical size.