> ## Documentation Index
> Fetch the complete documentation index at: https://voltaire.tevm.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Uint.toNumber

> Convert Uint256 to JavaScript number

<Card title="Try it Live" icon="play" href="https://playground.tevm.sh?example=primitives/uint.ts">
  Run Uint examples in the interactive playground
</Card>

<Tabs />

## Safe Integer Range

<Warning title="Number Precision Limits">
  JavaScript numbers are 64-bit floats. Only integers in range \[-2^53 + 1, 2^53 - 1] are safe.

  Values exceeding Number.MAX\_SAFE\_INTEGER (9007199254740991) will throw.
</Warning>

```typescript theme={null}
// Safe values
Uint.toNumber(Uint(0n))                         // 0
Uint.toNumber(Uint(9007199254740991n))         // OK: MAX_SAFE_INTEGER

// Unsafe values throw
Uint.toNumber(Uint(9007199254740992n))         // Error: too large
Uint.toNumber(Uint(10n ** 18n))                // Error: too large
```

## Usage Patterns

### Array Indices

```typescript theme={null}
const index = Uint(5n)
const arr = [1, 2, 3, 4, 5, 6]
const value = arr[Uint.toNumber(index)]  // 6
```

### Safe Conversion

```typescript theme={null}
function toNumberSafe(uint: BrandedUint256): number | null {
  try {
    return Uint.toNumber(uint)
  } catch {
    return null
  }
}
```

## See Also

* [fromNumber](/primitives/uint256/from-number) - Create from number
* [toBigInt](/primitives/uint256/to-bigint) - Convert to BigInt (no limits)
