To convert an IP address to a number, calculate a×256³ + b×256² + c×256 + d from the four octets of an IPv4 address.
The result is the address’s unsigned 32-bit integer representation, ranging from 0 through 4294967295. The IP to Decimal Converter performs that conversion and the reverse using exact integer arithmetic within JavaScript’s safe-integer range, so the result never picks up floating-point rounding.
Here, “IP address to number” means converting one dotted-decimal IPv4 address. It does not mean converting a hostname, an IPv6 address, a subnet, or another kind of identifier.

What an IPv4 number represents
An IPv4 address contains 32 bits arranged as four 8-bit octets, and RFC 791 defines the IPv4 address format. Dotted-decimal notation displays each octet as a decimal integer from 0 through 255. The numeric form reads those same 32 bits as a single unsigned integer.
The octets have fixed positional weight. The first octet occupies the most significant eight bits, while the fourth occupies the least significant eight bits. That is why the conversion is expressed in powers of 256 rather than by joining the four decimal octets together.
The full numeric range is 0 through 4294967295. The converter always presents this unsigned value, so an address in the upper half of the IPv4 range remains a positive result. A signed 32-bit destination may represent the same bits differently, which matters when transferring the result into code or a database.
Calculate the number with base 256
For an address written as a.b.c.d, the first octet is multiplied by 256³, the second by 256², the third by 256, and the fourth by 1. The four products are then added to form the integer.
For 192.168.1.1, the calculation is:
192×16,777,216 + 168×65,536 + 1×256 + 1
= 3,221,225,472 + 11,010,048 + 256 + 1
= 3,232,235,777
Manual arithmetic is possible, but the place values are easy to misplace. The converter applies the same base-256 folding process to each valid input and displays the exact result for comparison or copying.
Convert an IPv4 address to a decimal number
Use the following workflow to convert one strict value and move it safely into its destination:
- Choose the conversion direction. Select “IPv4 to decimal” for a dotted address or “decimal to IPv4” for an integer.
- Enter one strict value. Dotted input must contain exactly four unpadded decimal integers separated by periods, with every octet from 0 through 255. Decimal input must contain digits only, use no leading zeroes except the value 0 itself, and remain within 0 through 4294967295. Do not include spaces, signs, fractions, hexadecimal notation, omitted octets, prefixes, or CIDR suffixes.
- Convert and compare the displayed result. Check the exact output shown by the converter rather than trying to infer or round it separately.
- Copy the value and confirm the destination type. Store it as unsigned 32-bit data or a wider safe integer type, as appropriate for the application.
Input forms the converter accepts
Strict parsing prevents a valid-looking string from being interpreted under several incompatible rules. The supported input and rejection rules are:
| Input form | Outcome | Reason |
|---|---|---|
| Dotted form such as 192.168.1.1 | Accepted | Exactly four unpadded decimal octets are present, and each is within 0–255. |
| Decimal form such as 4294967295 | Accepted | The digits represent a value within the full unsigned 32-bit range. |
| 010.0.0.1 | Rejected | Leading zeroes can be interpreted inconsistently, including as octal by legacy software. |
| 192.168.1.1/24 | Rejected | The converter handles individual addresses, not CIDR prefixes or subnet ranges. |
| 192.168.1.256 | Rejected | An IPv4 octet cannot exceed 255. |
| 192.168.1 | Rejected | All four octets must be supplied; omitted octets are not inferred. |
Spaces are rejected rather than trimmed, and signs, fractions, and hexadecimal notation are not accepted. In decimal mode, a leading zero is permitted only when the entire value is simply 0. These restrictions remove ambiguity instead of guessing which interpretation the user intended.
Turn a decimal number back into IPv4
Reverse conversion uses exact division and remainder operations. The decimal value is divided repeatedly by 256. Each remainder supplies one base-256 component, while the quotient continues to the next component. After four components have been extracted, they are formatted from most significant to least significant as a dotted-decimal IPv4 address.
This direction is useful when a database, export, or API response contains an integer address field and you need to inspect the dotted form. The reverse workflow follows the same strict range and formatting rules as the forward direction; it does not query a registry or attempt to identify the host.
Where numeric IPv4 values are useful
A numeric representation can simplify comparisons, compact database keys, and systems that already exchange addresses as integers. It does not replace the dotted address everywhere, because each representation serves a different purpose.
- Database records can store one integer and compare it numerically when the column type is numeric.
- Spreadsheets and structured exports can carry an integer field for downstream processing.
- Firewall exports, test fixtures, and binary protocol notes may use numeric address values.
- Sorting systems designed for numeric comparison can avoid the lexical ordering produced by plain dotted strings.
| Use case | Benefit of the numeric form | Important check |
|---|---|---|
| Database storage and sorting | Supports numeric ordering and comparisons in a numeric column. | Use an unsigned 32-bit or wider numeric type; decimal text sorts lexicographically unless normalized. |
| Spreadsheet columns | Provides a compact integer field for formulas or record matching. | Confirm the cell is handled as a number, and retain the original address when provenance matters. |
| Firewall exports and test fixtures | Fits workflows that exchange address fields in integer form. | Numeric equality does not imply permission, ownership, or reachability. |
| Protocol notes and numeric comparisons | Makes address order explicit in systems designed around integer values. | Apply current network policy separately when classification matters. |
When moving a value into an application, be careful with signed storage. A signed 32-bit integer can display values above 2147483647 as negative. Use an unsigned 32-bit type, a wider integer type, or a validated decimal string as appropriate. For auditable records, preserve the original dotted input and document that the numeric column is the chosen representation.
Network meaning and privacy remain separate
Private, loopback, multicast, documentation, reserved, and public IPv4 addresses all pass through the same arithmetic conversion. A decimal result adds no network meaning and is not proof that an address is routable, safe, assigned, or appropriate for an access-control rule. Current address registries and network policy must be checked separately when classification matters.
The converter performs no DNS lookup, geolocation, reputation check, registry query, or external network request. All work stays in the browser, and no entered value is logged or stored by the tool. The output reflects the input’s numeric encoding rather than facts about its owner or location.
Scope limits and production checks
This workflow handles individual IPv4 addresses only. It does not accept CIDR prefixes, subnet ranges, masks, ports, hostnames, IPv6 addresses, or arbitrary-size integers. A suffix such as /24 is rejected rather than silently ignored. Use the Subnet Calculator for network, broadcast, host-range, and mask details. For an RFC 4291 IPv4-mapped IPv6 representation, use the IPv4 to IPv6 Converter; converting an integer does not create IPv6 connectivity.
For a production migration, compare a sample against a maintained IP-address library in the destination language and verify the database’s type boundaries before bulk conversion. For example, Python’s IPv4Address documentation provides a maintained reference for checking behavior in one common environment.
A small validation sample should cover normal addresses, boundary values, and the destination’s largest accepted integer. Keep the source representation alongside the numeric field when traceability matters, and record whether the stored value is an unsigned integer, a wider safe type, or a validated decimal string.
If you're weighing options, How to Convert IPv4 to IPv6 Address: Mapped Format covers this in detail.
If you're weighing options, PX to REM Cheat Sheet: Formulas, Root Size, Examples covers this in detail.