# Hex.toNumber

Decodes a [`Hex.Hex`](/api/Hex/types#hex) value into a number.

## Imports

:::code-group
```ts [Named]
import { Hex } from 'ox'
```

```ts [Entrypoint]
import * as Hex from 'ox/Hex'
```
:::

## Examples

```ts twoslash
import { Hex } from 'ox'

Hex.toNumber('0x1a4')
// @log: 420

Hex.toNumber(
  '0x00000000000000000000000000000000000000000000000000000000000001a4',
  { size: 32 }
)
// @log: 420
```

## Definition

```ts
function toNumber(
  hex: Hex,
  options?: toNumber.Options,
): number
```

**Source:** [src/core/Hex.ts](https://github.com/wevm/ox/blob/main/src/core/Hex.ts#L1003)

## Parameters

### hex

* **Type:** `Hex`

The [`Hex.Hex`](/api/Hex/types#hex) value to decode.

### options

* **Type:** `toNumber.Options`
* **Optional**

Options.

## Return Type

The decoded number.

`number`
