How to Convert IPv4 to IPv6

Convert any IPv4 address to its IPv6 forms: the IPv4-mapped ::ffff: address, the deprecated compatible form, and the 6to4 address. With worked hex examples.

Updated 6 min read By CodingEagles
Free tool IPv4 to IPv6 Converter IPv4-mapped, compatible and 6to4 forms of an IPv4 address. Open tool

An IPv4 address does not have a single IPv6 equivalent. It has a few, each built for a different job. The one most people mean is the IPv4-mapped address, written ::ffff:a.b.c.d, which carries the 32-bit IPv4 address inside an IPv6 address so a dual-stack system can reach IPv4 hosts. The IPv4 to IPv6 converter shows that form along with the compatible and 6to4 forms for any address you enter.

Here is what each form is and how it is built.

The IPv4-mapped form

IPv4-mapped addresses live in the ::ffff:0:0/96 block. The first 80 bits are zero, the next 16 bits are ffff, and the last 32 bits hold the IPv4 address. The result is usually written with the IPv4 part still in dotted-decimal, because that reads more clearly:

192.0.2.5  →  ::ffff:192.0.2.5

In pure hexadecimal the same address is ::ffff:c000:205, because 192.0.2.5 is c000:0205 in hex. Both spellings mean the same 128-bit value.

This is the representation you see most often in practice. When a server binds an IPv6 socket on a dual-stack machine, incoming IPv4 connections show up with the client address in this mapped form. That is why an IPv4 address often appears in logs with an ::ffff: in front of it.

Turning octets into hex

To build any of these forms by hand, you convert each pair of IPv4 octets into one 16-bit hex group. Take 192.0.2.5:

  • 192 in hex is c0, and 0 is 00, so the first group is c000.
  • 2 in hex is 02, and 5 is 05, so the second group is 0205.

So 192.0.2.5 is c000:0205. Those two groups are what get slotted into the IPv6 forms below.

The IPv4-compatible form

The IPv4-compatible address uses the ::/96 prefix: 96 zero bits followed by the 32-bit IPv4 address. For our example that is ::192.0.2.5, or ::c000:205 in hex.

This form is deprecated. It was an early idea for carrying IPv4 over IPv6 and is no longer used in new deployments, but the converter still shows it so you can recognise it if it turns up in old configuration or documentation. The mapped form replaced it for everyday dual-stack use.

The 6to4 form

6to4 is a tunneling scheme that gives an IPv4 host an entire IPv6 /48 to use. It embeds the IPv4 address into the 2002::/16 prefix:

192.0.2.5  →  2002:c000:205::/48

The two groups after 2002 are the IPv4 address in hex, c000:205. Because every 6to4 address derives from one IPv4 address, you can read the original IPv4 straight back out of it, which is what the IPv6 to IPv4 converter does in reverse.

Full versus compressed

Each of these forms can be written in full or compressed. The mapped address ::ffff:192.0.2.5 is already compressed; in full it is 0000:0000:0000:0000:0000:ffff:c000:0205. The converter shows both, since some older tools want the full eight-group spelling. If you only have the short form and need the long one, the rules are the same as for any IPv6 address; see how to expand an IPv6 address. To go the other way and tidy a long address up, see how to compress an IPv6 address.

When you actually need this

Most of the time you do not convert IPv4 to IPv6 by choice; you run into one of these forms and need to make sense of it. A mapped address in a log tells you which IPv4 client connected. A 6to4 prefix in a routing table tells you which IPv4 gateway it belongs to. Knowing which prefix means what saves you from guessing.

When you do need to produce one of these forms, enter the IPv4 address into the IPv4 to IPv6 converter. It returns the mapped, compatible and 6to4 forms together, each in compressed and full notation, so you can copy whichever one the system in front of you expects.

Frequently asked questions

What is the IPv6 version of an IPv4 address?
The usual answer is the IPv4-mapped address, written ::ffff:a.b.c.d. It places the 32-bit IPv4 address in the low bits of an IPv6 address under the ::ffff:0:0/96 prefix. For 192.0.2.5 that is ::ffff:192.0.2.5, or ::ffff:c000:205 in pure hex. This is the form dual-stack systems use to reach IPv4 hosts.
Is there one fixed IPv6 address for each IPv4 address?
No. The same IPv4 address has several IPv6 representations, each for a different purpose: the IPv4-mapped form for dual-stack sockets, the deprecated IPv4-compatible form, and the 6to4 form for tunneling. They encode the same 32 bits in different places, so they are not interchangeable.
How do I turn an IPv4 octet into hex for an IPv6 address?
Convert each pair of octets into one 16-bit group. 192.0 becomes c000 (192 is c0, 0 is 00) and 2.5 becomes 0205. So 192.0.2.5 is c000:0205 in hex, which is what you see in ::ffff:c000:205 and in the 6to4 prefix 2002:c000:205::.

Ready to try it?

IPv4-mapped, compatible and 6to4 forms of an IPv4 address. Free, in-browser, and 100% private — your data never leaves your device.

Open the IPv4 to IPv6 Converter