DevKitHub

Programming

IP Address Converter — Decimal, Hex, Binary, IPv6 and Reverse DNS

Enter an IPv4 or IPv6 address in any notation to see every other form, the special-purpose range it belongs to and its reverse DNS name. Legacy spellings such as 0300.0250.0.1 are read the way a browser reads them, and flagged.

IPv4Private-Use

192.168.0.1

Dotted decimal
192.168.0.1
Decimal32-bit integer
3232235521
Hex
0xC0A80001
Dotted hex
0xC0.0xA8.0x00.0x01
Octaldotted
0300.0250.00.01
Binary
11000000.10101000.00000000.00000001
IPv4-mapped IPv6::ffff:c0a8:1 in a URL
::ffff:192.168.0.1
Type
Private-Use, 192.168.0.0/16 (RFC 1918)
Globally reachableIANA registry
No
Reverse DNS namePTR
1.0.168.192.in-addr.arpa

This tool runs entirely in your browser. Your input is never uploaded, stored or logged.

How it works

An IPv4 address is a 32-bit number, and the dotted quad is only one way to write it. inet_aton, still behind getaddrinfo, ping and curl, also reads a part with a leading zero as octal, a part starting 0x as hex, a single number as all 32 bits, and three or two parts with the last one filling the remaining bits, so 192.168.1 is 192.168.0.1 and 127.1 is 127.0.0.1. The WHATWG URL Standard, which browsers, Node’s URL and fetch() follow, accepts all of those, plus a trailing dot, percent-encoding and full-width digits, which it maps to ASCII first. Python’s ipaddress and Go’s net.ParseIP reject every one of them. A server-side request filter that validates with a strict parser therefore decides the host is a name rather than an address, and the HTTP client behind it connects to 192.168.0.1. So each legacy form is parsed exactly as the URL Standard’s IPv4 parser does it, the address a browser would connect to is shown, and any disagreement with inet_aton is stated. Dotted binary is read back as well, because this page writes it, with a warning where a browser would read the same digits as octal.

IPv6 input can take any RFC 4291 form: leading zeros or none, one :: for a run of zero groups, a dotted IPv4 tail, brackets, and an RFC 4007 zone ID such as %eth0, which names an interface on your machine and is not part of the address. The canonical form follows RFC 5952: lowercase, no leading zeros, :: for the longest run of two or more zero groups and the first run on a tie, never for a single group, and dotted notation for IPv4-mapped addresses. The URL host row gives the all-hex form a browser writes instead. The expanded form, the 128-bit integer, the IPv4 address embedded in an IPv4-mapped, NAT64, 6to4 or Teredo address, and the reverse DNS name are shown too: the octets reversed under in-addr.arpa for IPv4, and 32 reversed hex digits under ip6.arpa for IPv6.

Every address is matched against the IANA IPv4 and IPv6 Special-Purpose Address Registries that RFC 6890 set up, as IANA publishes them today, most specific block first, with each entry’s Globally Reachable value. 100.64.0.0/10 comes out as shared address space for carrier-grade NAT rather than private, 169.254.169.254, the cloud metadata address, as link-local, and 192.0.0.9 as globally reachable although it sits inside 192.0.0.0/24. An IPv4-mapped address is named as such, with a warning about the IPv4 address inside it, because a dual-stack socket connecting to ::ffff:127.0.0.1 reaches loopback. One address at a time: a block with a prefix belongs in the subnet calculator.

Common problems

Every example below is run against this tool in our test suite, so what it says here is what the tool actually does.

This is not a valid IPv4 address. With 4 parts the last one takes 8 bits, so it must be below 256; it is 256.

192.168.1.256
Why:
Each of the four parts is one byte, so 256 does not fit. A browser rejects the whole host rather than wrapping the value, and so does inet_aton.
Fix:
Check the octet. With four parts, every one is 0–255.

This is not a valid IPv4 address. "08" starts with 0, so it is octal, and 8 and 9 are not octal digits.

192.168.08.1
Why:
A leading zero makes a part octal to inet_aton and to browsers alike, so 010 is 8 and 08 is not a number at all. Zero-padded addresses from spreadsheets and fixed-width logs hit this.
Fix:
Remove the leading zeros: 192.168.8.1.

"::" can appear only once in an address, or the number of zero groups would be ambiguous.

2001:db8::1::2
Why:
Each :: stands for as many zero groups as it takes to make eight, so with two of them there is no telling how the zeros are split between them.
Fix:
Keep one :: and write the other run of zeros out as 0 groups.

This converts a single address. For a block with a prefix such as /24, use the CIDR subnet calculator.

10.0.0.0/8
Why:
A prefix length describes a range of addresses, and a range has no single decimal, hex or reverse DNS form.
Fix:
Remove the /8 to convert the address, or use the CIDR subnet calculator for the range.

0300.0250.0.1 passed a filter that blocks 192.168.0.0/16.

Why:
Browsers and inet_aton read the leading zeros as octal and connect to 192.168.0.1, while strict parsers reject the text as not an address, so a filter built on one of those treats it as a host name.
Fix:
Resolve the host the way the client will, check the resulting address, and connect to that address rather than resolving it a second time.

::ffff:127.0.0.1 passed an IPv4 loopback check.

Why:
It is an IPv4-mapped IPv6 address. A dual-stack socket that connects to it reaches 127.0.0.1 over IPv4, but a check that only looks at IPv4 ranges never sees an IPv4 address.
Fix:
Unwrap IPv4-mapped addresses before checking ranges: ipv4_mapped in Python’s ipaddress, Unmap() on a Go netip.Addr.

Frequently asked questions

How do I convert an IP address to a decimal number?
Multiply each part by its place value and add them up: a × 16,777,216 + b × 65,536 + c × 256 + d. 192.168.0.1 is 192 × 16,777,216 + 168 × 65,536 + 0 + 1 = 3232235521. Browsers and ping accept that number as the address.
Why does 127.1 work as an address?
Because inet_aton, and the URL Standard after it, let the last part fill every byte the missing parts would have held. 127.1 is 127 followed by 1 as a 24-bit number, which is 127.0.0.1. It is legal, rarely intended, and a common way past filters that match addresses as text.
Is 100.64.0.0/10 a private range?
Not in the RFC 1918 sense. RFC 6598 reserves it as shared address space for carrier-grade NAT between an ISP and its customers. It is not globally reachable, but it is also not yours to number a LAN with, because your ISP may already be using it.
What is the reverse DNS name of an IP address?
The name a PTR record is published under. For IPv4 the octets are reversed under in-addr.arpa, so 192.0.2.1 becomes 1.2.0.192.in-addr.arpa. For IPv6 all 32 hex digits of the expanded address are reversed, one per label, under ip6.arpa.

Last updated