IPv6 ↔ BigInt Converter

Convert IPv6 addresses to/from 128-bit integers

Quick Convert

Batch Input

Results

Results will appear here

About IPv6 Integers

IPv6 addresses are 128-bit integers, ranging from 0 to 2128-1 (340,282,366,920,938,463,463,374,607,431,768,211,455). This tool uses JavaScript's BigInt for precise handling of these large numbers.

The IPv6 to BigInt Converter transforms IPv6 addresses between hexadecimal colon notation and their underlying 128-bit integer representation using BigInt for full precision. Enter an address like 2001:db8::1 to get 42540766411282592856903984951653826561, or paste a large decimal number to get the corresponding IPv6 address in both compressed and expanded forms.

Understanding BigInt for IPv6 Addresses

IPv4 addresses are 32-bit numbers that fit comfortably in a standard integer type -- the largest value is about 4.3 billion, well within the range of any modern programming language's number type. IPv6 is a completely different story. With 128 bits, the address space spans from 0 to 340,282,366,920,938,463,463,374,607,431,768,211,455 -- a number so large it has 39 digits. No standard 64-bit integer can hold it, and JavaScript's Number type loses precision for integers larger than about 9 quadrillion (2^53).

This is why BigInt exists. BigInt is an arbitrary-precision integer type available in JavaScript, Python, Java, and most modern languages. It can represent numbers of any size without rounding or precision loss, making it the right tool for IPv6 address arithmetic. When you convert an IPv6 address to its numeric form, you need BigInt to get an exact result. Using a regular 64-bit integer or a floating-point number would silently round the value, producing an address that is close to but not the same as the one you started with -- a subtle bug that can be very hard to track down.

The practical applications of BigInt IPv6 conversion mirror those of IPv4-to-integer conversion, but the scale is different. Database storage, range calculations, sequential enumeration, and subnet boundary computation all work the same way conceptually, but require BigInt arithmetic instead of standard integer math. If you are building an IPv6-aware application, understanding this conversion is foundational -- it is how you go from the human-readable colon-hex format to something a database or algorithm can efficiently work with.

How to Convert IPv6 to BigInt (and Back)

  1. Enter an IPv6 address in any valid notation (compressed, expanded, or mixed) or a decimal integer from 0 to 2^128 - 1
  2. Click Convert to see the equivalent representation in the other format
  3. View the full BigInt value, scientific notation approximation, and both compressed and expanded IPv6 forms

IPv6 to BigInt Conversion Examples

IPv6 AddressBigInt Value
::0
::11
::ffff:192.168.1.1281473913978881
fe80::1338288524927261089654018896841347694593
2001:db8::142540766411282592856903984951653826561
2001:db8::ff00:42:832942540766411282592856904136881884209961
ff02::1338963523518870617245727861372981592065
ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff340282366920938463463374607431768211455

Step-by-Step Conversion: 2001:db8::1

Expanded:  2001:0db8:0000:0000:0000:0000:0000:0001

Hex digits: 20010db8000000000000000000000001

BigInt:    0x20010db8000000000000000000000001
         = 42540766411282592856903984951653826561

Reverse Conversion: BigInt 1 to ::1

BigInt:     1
Hex:        0x00000000000000000000000000000001
Grouped:    0000:0000:0000:0000:0000:0000:0000:0001
Compressed: ::1

When to Use the IPv6 BigInt Converter

  • Database storage for IPv6 -- store IPv6 addresses as 128-bit integers in databases that support large numeric types (PostgreSQL numeric, MySQL DECIMAL(39,0), or two BIGINT columns for high/low 64-bit halves)
  • Address range arithmetic -- calculate the number of addresses in an IPv6 prefix by computing 2^(128 - prefix_length), operations that require BigInt precision
  • Subnet boundary calculation -- find the network address by applying a bitmask: BigInt_address & BigInt_mask, and the broadcast by: BigInt_address | ~BigInt_mask
  • Sequential address enumeration -- generate consecutive IPv6 addresses by incrementing the BigInt value, useful for scanning or allocation tools
  • IPv6-aware sorting -- sort IPv6 addresses numerically by comparing their BigInt values, avoiding the complexity of comparing colon-hexadecimal strings
  • Address space visualization -- convert prefix boundaries to numeric ranges for plotting IPv6 allocations on number lines or heatmaps

How IPv6 to BigInt Conversion Works

The 128-Bit Address Space

IPv6 addresses are 128-bit values, producing integers in a range far beyond what standard number types can handle:

PropertyValue
Bits128
Minimum address:: = 0
Maximum addressffff:...:ffff = 340,282,366,920,938,463,463,374,607,431,768,211,455
Total addresses2^128 = ~3.4 x 10^38

Standard 64-bit integers max out at 2^63 - 1 (~9.2 x 10^18), which is roughly 3.7 x 10^19 times too small for IPv6. JavaScript's Number.MAX_SAFE_INTEGER is 2^53 - 1 (~9 x 10^15), even more limited. BigInt is required for lossless IPv6 address arithmetic.

Conversion Algorithm

  1. Expand the IPv6 address to full 8-group notation with leading zeros
  2. Concatenate all hex digits into a single 32-character hex string
  3. Parse the hex string as a base-16 BigInt value
// JavaScript BigInt conversion
const ipv6 = "2001:0db8:0000:0000:0000:0000:0000:0001";
const hex = ipv6.replace(/:/g, "");           // "20010db8000000000000000000000001"
const bigint = BigInt("0x" + hex);            // 42540766411282592856903984951653826561n

Database Storage Strategies

Since most databases lack a native 128-bit integer type, common approaches include:

-- PostgreSQL: Use NUMERIC for exact 128-bit storage
CREATE TABLE ipv6_addresses (
    id SERIAL PRIMARY KEY,
    address NUMERIC(39, 0) NOT NULL
);

-- MySQL: Use BINARY(16) for compact storage
CREATE TABLE ipv6_addresses (
    id INT AUTO_INCREMENT PRIMARY KEY,
    address BINARY(16) NOT NULL
);

-- Alternative: Split into two 64-bit halves
CREATE TABLE ipv6_addresses (
    id INT AUTO_INCREMENT PRIMARY KEY,
    address_high BIGINT UNSIGNED NOT NULL,
    address_low  BIGINT UNSIGNED NOT NULL
);

Practical Advice for BigInt IPv6 Operations

The most common mistake when working with BigInt IPv6 values is mixing BigInt and regular Number types. In JavaScript, BigInt and Number are incompatible -- you cannot add 1n to 1 without an explicit conversion. This means your entire address arithmetic pipeline needs to use BigInt consistently. If a function returns a Number where a BigInt was expected, the result will either throw a TypeError or silently lose precision, depending on the language and context.

When storing IPv6 addresses in a database, consider your query patterns before choosing a storage strategy. PostgreSQL's NUMERIC(39,0) stores the full BigInt and supports range queries, but it is slower than binary storage for exact-match lookups. MySQL's BINARY(16) is compact (exactly 16 bytes) and fast for exact matches, but range queries require converting to numeric values. The two-column BIGINT approach splits the address into upper and lower 64-bit halves, which works well for range queries if most of your filtering is on the network portion (upper 64 bits). Choose the strategy that matches how you actually query the data, not the one that looks cleanest in the schema.

For prefix size calculations, remember that IPv6 numbers get very large very fast. A /64 prefix contains 2^64 addresses -- about 18.4 quintillion. A /48 contains 2^80 addresses. These numbers are useful for understanding the scale of IPv6, but they are rarely meaningful for practical capacity planning. Nobody is going to run out of addresses in a /64, so the question is usually about how many /64 subnets you need, not how many addresses are in each one. Use BigInt arithmetic for boundary calculations, but think in terms of prefix counts for planning.

Frequently Asked Questions

Why can't I use a regular JavaScript number for IPv6 addresses?

JavaScript numbers are 64-bit IEEE 754 floating-point values that lose precision for integers larger than 2^53 (9,007,199,254,740,992). IPv6 addresses can reach 2^128, which is approximately 10^38 -- far beyond the safe integer range. Using Number would silently round the value, producing incorrect address conversions. BigInt provides arbitrary-precision integers without rounding.

How do I calculate the number of addresses in an IPv6 prefix?

Use BigInt exponentiation: 2n ** BigInt(128 - prefix_length). For example, a /64 prefix contains 2n ** 64n = 18,446,744,073,709,551,616 addresses. A /48 contains 2n ** 80n = 1,208,925,819,614,629,174,706,176 addresses. These numbers are too large for standard integer types but straightforward with BigInt.

Is there a performance cost to using BigInt instead of Number?

Yes. BigInt operations are slower than native Number operations because they require arbitrary-precision arithmetic. For most networking use cases -- converting addresses, computing ranges, comparing values -- the performance difference is negligible. BigInt arithmetic becomes noticeably slower only when performing millions of operations in tight loops, which is uncommon in address management tasks.

Which database type should I use for IPv6 addresses?

It depends on your use case. PostgreSQL's native inet or cidr types are the best option if you use PostgreSQL, as they handle IPv6 natively with built-in operators. For MySQL, BINARY(16) is compact and efficient. For cross-database portability, DECIMAL(39,0) or NUMERIC(39,0) work everywhere and support range queries, though they use more storage than binary alternatives.

Can I convert IPv4-mapped IPv6 addresses like ::ffff:192.168.1.1?

Yes. The tool first expands the mixed notation to full hexadecimal form (0000:0000:0000:0000:0000:ffff:c0a8:0101), then converts to BigInt normally. The resulting value is 281473913978881, which falls in the IPv4-mapped range (::ffff:0:0/96).

Related Tools

IPparseβ€’Free Network & Subnet Calculator Tools

Β© 2026 IPparse. All tools run locally in your browser.

100% Privacy-First β€’ No Data Collected