# ipToInt() function · @imqueue/net

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

Converts an address to the unsigned `bigint` this package compares with.

**Signature:**

```typescript
export declare function ipToInt(ip: string, type?: NetworkType): bigint;
```

## Parameters


| Parameter | Type | Description |
| --- | --- | --- |
| ip | string | the address to convert |
| type | [NetworkType](https://imqueue.org/api/net/latest/net.networktype/) | _(Optional)_ the family, if you already know it; omit to have it detected |


**Returns:**

bigint

The address as a single integer — 32 bits of range for IPv4, 128 for IPv6.

## Exceptions

TypeError if the address is not valid, or if `type` disagrees with it.

## Remarks

The bridge between text and every numeric operation here: ranges, sorting and binary search all work on these values. Because the two families are converted into the same unsigned space and IPv4 occupies only its low 32 bits, values from different families must never be compared — which is why [Networks](https://imqueue.org/api/net/latest/net.networks/) keeps them apart.

