MM to PX Converter

Millimetres to CSS pixels at the specified 3.779528 to the millimetre, plus what those pixels actually measure on a real screen.

Enable JavaScript to customise; default output below.

Only affects the physical reality section. 96 is the CSS reference, 163 a 27-inch 4K, 227 a 13-inch MacBook Pro, 460 a current phone.

Live preview length.txt
210.0000mm = 793.7008px

210.0000mm in every absolute unit
  px                                      793.7008  ← out
  in                                      8.2677
  cm                                      21.0000
  mm                                      210.0000  ← in
  pt                                      595.2756
  pc                                      49.6063

The definitions these come from
  1 inch                                  96px, 2.54cm, 25.4mm, 72pt, 6pc
  1mm                                     3.779528px
  1cm                                     37.795276px
  1pt                                     1.333333px, which is why 12pt is 16px

Those 793.70 CSS pixels on a real screen
  at 96 ppi                               8.2677in, 21.0000cm
  the CSS answer assumes                  96 ppi
  so the real length is                   100.0% of the CSS one
  on a 1080p 24-inch monitor              219.13mm
  on the CSS reference pixel              210.00mm
  on a 27-inch 4K monitor                 123.68mm
  on a 13-inch MacBook Pro                88.81mm
  on an iPhone 15                         43.83mm

The absolute units in CSS are defined against each other, not measured:
one inch is exactly 96 pixels, 2.54 centimetres, 25.4 millimetres, 72
points and 6 picas. So 210.0000mm is 793.7008px exactly, and no screen
is involved in that conversion.

A CSS pixel is not a device pixel and not a physical length. It is about
1/96 inch on a 96 ppi monitor and about a quarter of that on a phone,
where the browser draws one CSS pixel with several device pixels. That
is the whole reason `1cm` in a stylesheet does not measure a centimetre
on screen.

Physical units belong in a print stylesheet, where the browser knows the
paper size and the conversion means something. In a screen stylesheet
they are a slower way of writing pixels, and they break when a reader
zooms.

The inch has been exactly 2.54 centimetres since the international
agreement of 1959. Rounding it to 2.5 is an error of 1.6 percent, which
is four millimetres across a sheet of A4 and enough to lose a bleed.

12pt is 16px, and that is where the browser default font size comes
from. A point is 1/72 inch in publishing and CSS keeps that definition,
which is why type specified in points from a design tool converts to
pixels cleanly.

`rem` and `em` are the units to reach for in a stylesheet. They scale
with the reader's font size, which is a preference that people set
deliberately and that fixed physical units ignore.

For anything that will be printed, work in millimetres and set the
resolution separately. The pixel dimensions needed follow from the print
size and the resolution, and a file specified in pixels alone has no
physical size at all.

Output is valid and updates as you type.

One millimetre is 3.779528 CSS pixels. That is not a measurement of anything: it follows from the CSS specification defining one inch as exactly 96 pixels, and 25.4 millimetres to the inch.

Which means the conversion is exact and the result is not a millimetre. 210mm in a stylesheet becomes 793.7 CSS pixels, and those pixels measure 210mm only on a display at exactly 96 pixels per inch. On a 13-inch MacBook Pro they measure 89mm. On a phone, 44mm.

So millimetres are dependable in a print stylesheet, where the browser knows the paper, and a slower way of writing pixels everywhere else.

How to use

  1. Put in the length in millimetres.
  2. Read the pixel figure, and the rest of the units alongside it.
  3. Set a screen density if you want to know what those pixels actually measure.

Example

The width of an A4 page:

210.0000mm = 793.7008px

210.0000mm in every absolute unit
  px                                      793.7008  ← out
  in                                      8.2677
  cm                                      21.0000
  mm                                      210.0000  ← in
  pt                                      595.2756
  pc                                      49.6063

The definitions these come from
  1 inch                                  96px, 2.54cm, 25.4mm, 72pt, 6pc
  1mm                                     3.779528px
  1cm                                     37.795276px
  1pt                                     1.333333px, which is why 12pt is 16px

Those 793.70 CSS pixels on a real screen
  at 96 ppi                               8.2677in, 21.0000cm
  on a 1080p 24-inch monitor              219.13mm
  on a 27-inch 4K monitor                 123.68mm
  on a 13-inch MacBook Pro                88.81mm
  on an iPhone 15                         43.83mm

A4 is 210mm on paper and somewhere between 44mm and 219mm on a screen, depending on the screen. That range is the reason to be careful with physical units.

Pitfalls

The conversion is exact, the physical result is not. 3.779528 px/mm is arithmetic from a definition. Whether those pixels occupy a millimetre depends on the display, and no modern display is 96 ppi.

Do not lay out a screen in millimetres. It is slower to read, it does not respond to a reader’s zoom in the way rem does, and it implies a physical precision the browser cannot deliver. Use rem for type and spacing, and percentages or grid for layout.

Millimetres are right for print stylesheets. Inside @media print the browser knows the paper size, so @page { margin: 20mm } does what it says. That is the one place these units earn their keep.

A 3mm bleed is 11.34px and that is not a useful number. For print work, stay in millimetres all the way through and set the resolution separately: the pixel dimensions follow from the print size and the PPI, which is a different calculation.

Rounding the conversion accumulates. 3.78 instead of 3.779528 is 0.05 percent, which is a tenth of a millimetre across A4. Fine for a margin, visible on a grid of 30 columns.

The mm in an SVG is a different question again. An SVG with a viewBox and a width in millimetres scales its user units to that physical width, so the same drawing can be both, which is exactly why SVG is the right format for something that has to print at a known size.

Compatibility

Arithmetic in the browser: nothing is uploaded and nothing is stored.

The relationships used are the CSS Values and Units definitions: 1in = 96px = 2.54cm = 25.4mm = 72pt = 6pc. They are exact and every browser implements them identically, because there is nothing to measure. The round trip is checked across every pair of units in the test suite.

The screen densities are real: about 92 ppi for a 1080p 24-inch monitor, 163 for a 27-inch 4K, 227 for a 13-inch MacBook Pro, 460 for a current iPhone. They are there to show how far the CSS reference pixel has drifted from any hardware.

mm works in every browser and has since the beginning. What varies is whether it means anything, which depends on where you use it.

Frequently asked questions

How many pixels is 1mm?
3.779528 CSS pixels, from 96 divided by 25.4. In device pixels it depends on the screen’s density and the device pixel ratio, which is why the question usually has a different answer than the asker expects.
Why is my millimetre not a millimetre on screen?
Because CSS defines the millimetre against a 96 pixels-per-inch reference rather than against the actual display. Every phone and laptop is denser than that, so the on-screen length comes out smaller.
What should I use instead for layout?
rem for type and spacing, so it scales with the reader’s font size; percentages, fr units or clamp() for layout. Physical units only for print.
Does this work for print CSS?
Yes, and that is where it belongs. Set @page margins in millimetres, size elements in millimetres, and the browser’s print pipeline converts to the paper correctly.
How do I get from millimetres to image pixels for printing?
Divide the millimetres by 25.4 to get inches, then multiply by the print resolution: 210mm at 300 ppi is 2,480 pixels. The DPI to PPI converter on this site does that and explains why 300 is the number.
Weekly drops

New tools, when there are new tools

One email when something worth using ships. No schedule to fill, so no filler.

Your address goes nowhere else, and one click unsubscribes.