MM to PX for JavaScript

Convert millimeters to pixels and generate a reusable JavaScript conversion expression.

JavaScript dimensions

mm
mm
PPI

JavaScript output

Width
Height
Points
Megapixels

JavaScript output

Use 96 PPI for CSS pixels or supply the actual device or export resolution your code targets.

How MM to PX for JavaScript Works

📐

Enter the mm value

Type the millimeter value you want to convert programmatically.

⚙️

Set the target PPI

Choose 96 PPI for DOM/CSS work, or enter a custom resolution for canvas or export code.

💻

Copy the code snippet

The calculator generates a JavaScript expression you can paste directly into your codebase.

When working with the DOM or CSS in JavaScript, pixel values correspond to CSS reference pixels at 96 PPI. For HTML Canvas or image-processing libraries, you may need a different resolution. The generated conversion function lets you pass any millimeter value and receive the pixel equivalent at your chosen PPI.

MM to PX for JavaScript Formula

const px = mm => mm * DPI / 25.4 Conversion Formula

This one-liner converts any millimeter value to pixels at the specified DPI. At 96 PPI (CSS standard), the multiplier is approximately 3.7795. Swap in your target DPI for canvas or export workflows.

DOM element
10 × (96 ÷ 25.4)
= 37.7953 px
Canvas (150 PPI)
10 × (150 ÷ 25.4)
= 59.0551 px
Print (300 PPI)
10 × (300 ÷ 25.4)
= 118.1102 px
Reverse Formula
const mm = px => px * 25.4 / DPI

MM to PX for JavaScript Conversion Chart

JavaScript conversion values at common resolutions. Use 96 PPI for CSS pixel calculations and 300 PPI for print-resolution canvas work.

mm 72 PPI96 PPI150 PPI300 PPI
1 mm 2.83463.77955.905511.8110
2 mm 5.66937.559111.811023.6220
5 mm 14.173218.897629.527659.0551
10 mm 28.346537.795359.0551118.1102
15 mm 42.519756.692988.5827177.1654
20 mm 56.692975.5906118.1102236.2205
25 mm 70.866194.4882147.6378295.2756
50 mm 141.7323188.9764295.2756590.5512
100 mm 283.4646377.9528590.55121181.1024