piapia123
en

IP to Integer

Web

Everything runs locally in your browser — nothing is uploaded

Input
Drop a file here to load its contents
Output

Convert an IP address to its integer forms and back — both directions. Type `192.168.1.1` to get its numeric readings, or `3232235777` to get the address. Why does this deserve a tool? Storing an IP as an integer is standard database practice — 4 bytes instead of 15, and range queries work directly on it. Which means everyone who has built such a table hits the same question: why does it come back negative? The answer is that a MySQL `INT` column is signed: `192.168.1.1` is stored as `-1062731519`. So the unsigned and signed readings are shown as two separate rows — the signed one is not padding, it is what many people came here for. ⚠️ The reverse direction does not guess: entering `-1` produces an error rather than silently becoming `255.255.255.255`. Which address that is depends on how it was stored, and guessing wrong hands you a wrong firewall rule. IPv6 is handled as a full 128-bit value (the decimal row is long, but exact) — storing 128 bits in a normal number silently drops digits and yields an address that looks plausible and is wrong.

Features

  • Both directions, with automatic detection and a manual override
  • Unsigned and signed on separate rows — the direct answer to “why is it negative in my database”
  • Dotted decimal, hexadecimal and optional binary in one pass
  • For IPv4-mapped IPv6 (`::ffff:192.168.1.1`), the embedded IPv4 is shown too
  • Reverse DNS name (`1.1.168.192.in-addr.arpa`)
  • IPv6 uses exact 128-bit integers; beyond 128 bits it errors instead of wrapping
  • Negative input errors instead of guessing two’s complement
  • Everything is computed on your device

How to use

  1. Paste an IP address or an integer into the left pane
  2. The direction is detected automatically; override it if you like
  3. Results appear immediately, each row copyable on its own

FAQ

Why is the IP coming out of my database negative?
Because that column is a signed integer. A MySQL `INT` is signed 32-bit, so its range is roughly ±2.1 billion; `192.168.1.1` is 3232235777 unsigned, which is past the positive limit and therefore displays as `-1062731519` in two’s complement. The data is fine — it is the same bits read the other way. You can fix it by changing the column to `INT UNSIGNED`, or by casting when you read it. Both readings are shown side by side here so you can match them up at a glance.
What is the point of storing IPs as integers?
Two things: space (4 bytes instead of 15, and the index shrinks with it) and range queries. The second matters more. With strings, “find every record inside 192.168.0.0/16” means `LIKE '192.168.%'` — which also matches things like `192.168.0.1.example.com` and cannot use the index. Stored as an integer it is just `WHERE ip BETWEEN 3232235520 AND 3232301055`, and the index works.
Why can’t `-1` be converted? It is obviously `255.255.255.255`.
Under your storage scheme it is — but this tool does not know which scheme you use. The same `-1` reads as `255.255.255.255` under signed 32-bit, as `18446744073709551615` under unsigned 64-bit, and as yet another number under arbitrary precision. Guessing wrong about an IP can mean a wrong firewall rule or a record you did not intend to allow. So this errors instead, and shows both the unsigned and signed readings — one look at your schema tells you which applies.

Related tools