---
title: "cmToPixels utility"
description: "Convert centimeters to pixels for page formatting in Tiptap Pages."
canonical_url: "https://tiptap.dev/docs/pages/utilities/cm-to-pixels"
---

# cmToPixels utility

Convert centimeters to pixels for page formatting in Tiptap Pages.

The `cmToPixels` helper lets you easily convert centimeters to pixels, which is useful if you want to define your page or margin sizes in centimeters and need to convert them to pixels for the `pageFormat` option or custom layouts in the Tiptap Pages extension.

## Import

```js
import { cmToPixels } from '@tiptap-pro/extension-pages'
```

## API

```ts
cmToPixels(cm: number, dpi?: number): number
```

- `cm`: The value in centimeters to convert.
- `dpi` (optional): Dots per inch. If not provided, the utility will auto-detect the DPI of the current environment.
- **Returns:** The equivalent value in pixels (rounded).
