> **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.

# Hex.toBigInt

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

Decodes a [`Hex.Hex`](/docs/utilities/hex/types#hex) value into a BigInt.

## Imports

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

## Examples

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

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

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

## Definition

```ts
function toBigInt(
  hex: Hex,
  options?: toBigInt.Options,
): bigint
```

## Parameters

### hex

* **Type:** `Hex`

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

### options

* **Type:** `toBigInt.Options`
* **Optional**

Options.

#### options.signed

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

Whether or not the number of a signed representation.

#### options.size

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

Size (in bytes) of the hex value.

## Return Type

The decoded BigInt.

`bigint`
