# cidrToRangeInt() function · @imqueue/net

Source: https://imqueue.org/api/net/latest/net.cidrtorangeint/
Published: 2026-08-01
Author: @imqueue maintainers (https://github.com/imqueue)
Package: @imqueue/net 3.0.2 — generated reference, not hand-written

Expands a CIDR record into the first and last address it covers, as integers.

**Signature:**

```typescript
export declare function cidrToRangeInt(cidr: string, type?: NetworkType): [bigint, bigint];
```

## Parameters


| Parameter | Type | Description |
| --- | --- | --- |
| cidr | string | a network in `address/prefix` form, e.g. `10.0.0.0/8` |
| type | [NetworkType](https://imqueue.org/api/net/latest/net.networktype/) | _(Optional)_ the family, if known; omit to have it detected from `cidr` |


**Returns:**

\[bigint, bigint\]

A `[first, last]` tuple. Both ends are inclusive, so a `/32` returns the same value twice.

## Exceptions

TypeError if the address part is invalid or disagrees with `type`.

RangeError if there is no `/prefix`. A bare `10.0.0.1` makes the prefix `undefined`, which reaches `BigInt(NaN)` — so the failure surfaces as `Cannot convert NaN to a BigInt` rather than as a message about the record. This is why every network given to [Networks](https://imqueue.org/api/net/latest/net.networks/) needs an explicit prefix length, `/32` and `/128` included.

## Remarks

Host bits in the address are cleared rather than rejected, so `10.0.0.5/8` is accepted and yields the same range as `10.0.0.0/8`. The prefix itself is not bounds-checked: a value above the family width produces a negative shift and throws from `BigInt`, and a negative one produces a nonsensical range.

