> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://v3.viem.sh/api/mcp` to find what you need.

# Bytes.toNumber

:::info
`Bytes.toNumber` is a re-export of ox's [`Bytes.toNumber`](https://oxlib.sh/api/Bytes/toNumber). Refer to the ox documentation for the full reference.
:::

Decodes a [`Bytes.Bytes`](/docs/utilities/bytes/types#bytes) into a number.

## Imports

```ts
import { Bytes } from 'viem/utils'
```

## Examples

```ts twoslash
// @noErrors
import { Bytes } from 'viem/utils'

Bytes.toNumber(Bytes.from([1, 164]))
// @log: 420
```

## Definition

```ts
function toNumber(
  bytes: Bytes,
  options?: toNumber.Options,
): number
```

## Parameters

### bytes

* **Type:** `Bytes`

### options

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

#### options.signed

* **Type:** `boolean`
* **Optional**

Whether or not the number of a signed representation.

#### options.size

* **Type:** `number`
* **Optional**

Size of the bytes.

## Return Type

`number`
