How Long Is An IP Address? | Numbers That Matter

An IPv4 address is 32 bits long, while an IPv6 address is 128 bits long.

That answer is simple, but it can mean three different things in real work: the binary size computers store, the written length people see, or the prefix length used for routing. Mixing those up can break forms, logs, firewall rules, and databases.

IPv4 and IPv6 don’t just look different. They were built with different sizes, formats, and room for growth. IPv4 uses four number blocks. IPv6 uses eight hexadecimal groups, often shortened with compression rules. Once you know which “length” you mean, the answer becomes easy to apply.

IP Address Length In Bits, Bytes, And Text

The technical length of an IP address is measured in bits. A bit is a single binary digit: 0 or 1. Eight bits make one byte. IPv4 has 32 bits, so it takes 4 bytes. IPv6 has 128 bits, so it takes 16 bytes.

The written form is different. IPv4 usually appears as dotted decimal, like 192.168.1.1. IPv6 usually appears as hexadecimal groups, like 2001:db8:85a3::8a2e:370:7334. The written text can shrink or grow depending on zero compression and notation style.

Why IPv4 Is 32 Bits

IPv4 has four octets. Each octet holds 8 bits, and each one can range from 0 to 255. Four octets make 32 bits total. That gives IPv4 about 4.29 billion possible combinations before reserved ranges, private ranges, and special blocks are removed.

The original RFC 791 IPv4 specification defines the classic Internet Protocol format that made 32-bit addressing standard. In text, the longest normal IPv4 address has 15 characters, such as 255.255.255.255.

Why IPv6 Is 128 Bits

IPv6 was made much larger because 32-bit addressing could not leave enough room for global growth. IPv6 has 128 bits, written as eight groups of four hexadecimal characters. Each group is 16 bits.

The RFC 8200 IPv6 specification states that IPv6 expands address size from 32 bits to 128 bits. In full written form, the longest standard IPv6 address has 39 characters.

How Written IP Addresses Change In Length

A written address is not always the same length as the binary value behind it. IPv4 is steady enough for most forms, but IPv6 changes more because leading zeros can be removed and long runs of zero groups can be shortened with ::.

For IPv6, 2001:0db8:0000:0000:0000:ff00:0042:8329 and 2001:db8::ff00:42:8329 can represent the same value. The second version is shorter, but the actual network value stays 128 bits.

Form Length Plain Meaning
IPv4 binary 32 bits / 4 bytes The machine-level size of an IPv4 address.
IPv4 dotted decimal 7 to 15 characters Human-readable form, from 0.0.0.0 to 255.255.255.255.
IPv6 binary 128 bits / 16 bytes The machine-level size of an IPv6 address.
Full IPv6 text 39 characters Eight four-character hex groups with seven colons.
Compressed IPv6 text 2 to 39 characters Zeros may be shortened, with :: used once.
IPv4-mapped IPv6 text Up to 45 characters A safe text ceiling used by many databases and logs.
CIDR prefix /0 to /32 or /128 Shows network size, not written character length.
Port number Not part of the IP address :443 or :8080 belongs to the connection endpoint.

How Long Is An IP Address? In Real Storage

When developers ask this question, they often mean storage size. For binary storage, IPv4 needs 4 bytes and IPv6 needs 16 bytes. That’s compact, reliable, and easy to compare.

For text storage, IPv4 fits in 15 characters. IPv6 needs more room. A field of 45 characters is a common safe choice when logs or apps may receive IPv6 in mixed notation. Better database types, such as PostgreSQL inet, can reduce mistakes because they understand IP data instead of treating it as plain text.

Routing data adds another layer. The IANA IPv4 address space registry tracks IPv4 blocks and assignments, which is separate from the length of a single address. A block like 192.0.2.0/24 means the first 24 bits identify the network portion.

What CIDR Prefix Length Means

A slash number is not the same as address length. In 192.168.1.0/24, the IPv4 address is still 32 bits. The /24 means the first 24 bits are the network part, leaving 8 bits for host values.

In IPv6, 2001:db8::/32 is still inside a 128-bit system. The slash value tells routers how many starting bits belong to the network. It does not change the full address size.

Task Good Choice Why It Works
Database storage Binary 16 bytes or native IP type Handles both IPv4 and IPv6 with fewer text errors.
Simple text field 45 characters Leaves room for IPv6 and mapped forms.
Web form validation Separate IPv4 and IPv6 checks Prevents valid IPv6 compression from being rejected.
Log files Keep the raw value Preserves what the server received.
Security rules Store CIDR blocks, not only single IPs Matches real network ranges.

Common Mistakes With IP Address Length

One mistake is setting every IP field to 15 characters. That works for IPv4 only. The first valid IPv6 user can get blocked, logged poorly, or stored with missing data.

Another mistake is treating the port as part of the IP address. In 192.0.2.10:443, the IP address is 192.0.2.10. The port is 443. IPv6 with ports is usually wrapped in brackets, like [2001:db8::1]:443, so software can tell the colons apart.

A third mistake is assuming every public-looking value is safe to reveal. IP addresses can point to a network, a device, or a service pattern. Masking part of the value in screenshots and public logs is often the safer move.

How To Read IP Length Without Getting Lost

Ask what type of length you need before making a choice. If you’re studying networking, use bits. If you’re building a form, use characters. If you’re setting firewall rules, read the slash prefix.

  • IPv4: 32 bits, 4 bytes, usually up to 15 characters in text.
  • IPv6: 128 bits, 16 bytes, up to 39 characters in full standard text.
  • Safe text storage: 45 characters gives room for mixed IPv6 notation.
  • CIDR: Slash numbers mark the network portion, not total address size.

Final Answer For Everyday Use

If someone asks for the length of an IP address, answer by version: IPv4 is 32 bits, and IPv6 is 128 bits. If they mean written length, IPv4 can take up to 15 characters, while standard full IPv6 takes up to 39 characters.

For forms, logs, and databases, don’t stop at the short answer. Plan for IPv6. A text field that only fits IPv4 is a quiet bug waiting to show up when real traffic arrives.

References & Sources