IP Address Converter — Dotted Decimal, Integer, Hex & Binary
Convert one IPv4 address between dotted decimal, 32-bit integer, hex and binary; also get octal, the legacy class, the in-addr.arpa name and the ::ffff: form.
IP Address Converter
Background.
Ask MySQL's INET_ATON() for 192.168.1.1 and it answers 3232235777. That number is not a code for the address; it is the address. RFC 791, the 1981 specification of the Internet Protocol, defines an address as four octets — 32 bits — and the dotted form is only a readable way to print them: each 8-bit group written in decimal, with a full stop between groups. Read the 32 bits as one unsigned number and you have the integer; write them four bits to a digit and you have hexadecimal; write every bit and you have binary. The converter moves between these in either direction.
Each notation lives somewhere different. The integer is what an unsigned 32-bit database column stores and what IP-range tables list, because numbers sort and compare correctly where text does not: as strings, "192.168.1.10" sorts before "192.168.1.9". Hexadecimal turns up in packet dumps and some logs, two digits to an octet. Binary is the view that makes subnet masks legible, since a /24 keeps exactly the first 24 bits.
Three more forms come from the same bits. The reverse-DNS name lists the octets backwards under in-addr.arpa, the name a resolver queries to find the hostname for an address. The IPv4-mapped IPv6 form, ::ffff: followed by the dotted address, is how dual-stack software shows an IPv4 client. The legacy class letter, read from the first octet, survives in textbooks and exams although the Internet moved to classless addressing in 1993.
The octal output is there as a warning. Under POSIX, inet_addr() reads any part that starts with 0 as octal, so 010 means 8, while other software reads the same text as decimal 10 or rejects it. Because the two readings point at different hosts, a dotted address with a leading zero is refused rather than guessed at.
What is ip address converter?
An IPv4 address is a 32-bit unsigned number, from 0 to 4,294,967,295, that identifies a network interface. Dotted-decimal notation splits those bits into four octets of eight bits and writes each as a decimal number from 0 to 255; RFC 3986 gives the formal grammar, which caps every part at 255. With 2³² possible values the whole IPv4 space holds about 4.3 billion addresses, and each one has exactly one dotted form, one eight-digit hexadecimal form and one 32-bit binary form.
How to use this calculator.
- Set the input notation to match what you have: dotted decimal (192.168.1.1), the 32-bit integer (3232235777), hexadecimal (0xC0A80101) or binary.
- Paste the address on its own. A /24 or any other prefix is rejected; network and broadcast addresses belong to the IP subnet calculator.
- Hexadecimal can be typed with or without 0x and with fewer than eight digits, which are padded on the left, so 0xFFFF becomes 0.0.255.255. Binary must be exactly 32 ones and zeros, with or without dots between the octets.
- In dotted input, drop leading zeros: write 192.168.10.1, not 192.168.010.1.
- Copy the form you need: the integer for a database or range table, the in-addr.arpa name for a PTR record, the binary when working out a mask by hand.
The formula.
Dotted decimal to integer is place value in base 256: value = o₀ × 16,777,216 + o₁ × 65,536 + o₂ × 256 + o₃, where o₀ is the first octet and 16,777,216 is 256³. Going back, each octet is the integer divided by its place value, rounded down, then reduced modulo 256: o₀ = ⌊value ÷ 16,777,216⌋ mod 256, and so on down to o₃ = value mod 256. Hexadecimal is the same integer in base 16, padded to eight digits; because 16² = 256, every octet maps to exactly two hex digits with no carrying between them. Binary writes each octet in base 2, padded to eight bits. The octal form writes each octet in base 8 behind a leading 0, so it has no fixed width: 0 prints as 00, 1 as 01 and 192 as 0300. The class is read from the first octet alone: 0–127 is A, 128–191 B, 192–223 C, 224–239 D (multicast) and 240–255 E (reserved), matching RFC 791's leading-bit rule of 0 for A, 10 for B and 110 for C.
A worked example.
Take 10.20.30.40, an address in the 10.0.0.0/8 block that RFC 1918 sets aside for private networks. Its octets are 10, 20, 30 and 40, so the integer is 10 × 16,777,216 + 20 × 65,536 + 30 × 256 + 40 = 167,772,160 + 1,310,720 + 7,680 + 40 = 169,090,600. In hexadecimal each octet becomes two digits — 10 is 0A, 20 is 14, 30 is 1E and 40 is 28 — giving 0x0A141E28. In binary the octets read 00001010.00010100.00011110.00101000, and in octal 012.024.036.050. The first octet, 10, is below 128, so the legacy class is A. Wrapped for IPv6 the address is ::ffff:10.20.30.40, and reversed for DNS it is 40.30.20.10.in-addr.arpa. The octal line shows why leading zeros cause trouble. A C program passing "012.024.036.050" to inet_addr() gets 10.20.30.40 back, but "010.020.030.040" would come back as 8.16.24.32.
Frequently asked questions.
How do I turn a dotted IP address into a single decimal number by hand?
Why does my JavaScript IP conversion return a negative number?
Is 192.168.010.1 the same address as 192.168.10.1?
Why is the reverse-DNS name written backwards?
What does ::ffff: in front of an IPv4 address mean?
Does the class of an IP address still matter?
Can a bare number like 2130706433 be used as an address?
References& sources.
- [1]Postel, J. (ed.) (1981). RFC 791, Internet Protocol — DARPA Internet Program Protocol Specification, §2.3 Function Description and §3.2 Discussion. "Addresses are fixed length of four octets (32 bits)." The same section defines the classful split by leading bits: "in class a, the high order bit is zero … in class b, the high order two bits are one-zero … in class c, the high order three bits are one-one-zero". Source for the 32-bit width and the legacy class output.
- [2]Berners-Lee, T., Fielding, R. & Masinter, L. (2005). RFC 3986, Uniform Resource Identifier (URI): Generic Syntax, §3.2.2 Host. Gives the formal ABNF for dotted-decimal notation — IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet — with dec-octet bounded at "25" %x30-35, i.e. 0–255. Source for the per-octet range this calculator enforces.
- [3]IEEE and The Open Group (2018). IEEE Std 1003.1-2017 (POSIX.1-2017), System Interfaces: inet_addr(). Specifies the a.b.c.d, a.b.c, a.b and a forms, and states that "All numbers supplied as parts in IPv4 dotted decimal notation may be decimal, octal, or hexadecimal, as specified in the ISO C standard". Source for the octal output and for rejecting leading zeros in dotted input.
- [4]Hinden, R. & Deering, S. (2006). RFC 4291, IP Version 6 Addressing Architecture, §2.2 Text Representation of Addresses and §2.5.5.2 IPv4-Mapped IPv6 Address. Defines the 80-zero-bits + FFFF + IPv4 layout and the mixed textual form x:x:x:x:x:x:d.d.d.d, with the example ::FFFF:129.144.52.38. Source for the IPv4-mapped IPv6 output.
- [5]Mockapetris, P. (1987). RFC 1035, Domain Names — Implementation and Specification, §3.5 IN-ADDR.ARPA domain. "Thus data for Internet address 10.2.0.52 is located at domain name 52.0.2.10.IN-ADDR.ARPA"; "The reversal, though awkward to read, allows zones to be delegated which are exactly one network of address space." Source for the reverse-DNS output.
- [6]Fuller, V. & Li, T. (2006). RFC 4632, Classless Inter-domain Routing (CIDR): The Internet Address Assignment and Aggregation Plan, §2 and §3.1. Records the decision to "deprecate the Class A/B/C network address assignment system in favor of using 'classless', hierarchical blocks of IP addresses (referred to as prefixes)". Source for labelling the class output as legacy.
How this page was produced
- Published by
- Quanta Calculator
- Overseen by
- Daniel, Quanta Calculator Researcher
- Primary sources
- 6 cited below
- Method
- value = ((o₀·256 + o₁)·256 + o₂)·256 + o₃
- Published
- Last verified
Built with AI assistance and verified by automated tests against the cited sources — every worked example on this page is computed by the same code that runs the calculator. How we build and check calculators.
In this category
Embed
Quanta Pro
Paid features are coming later.
- All 1560 calculators remain free
- No billing is enabled