Need to represent IPv4 addresses in IPv6 format? This guide covers everything about IPv4-to-IPv6 mapping via API, including mapping types, dual-stack networking, and implementation examples.
What is IPv4 to IPv6 Mapping?
IPv4-mapped IPv6 addresses allow IPv4 addresses to be represented in IPv6 format. This is essential for dual-stack systems that need to handle both protocols seamlessly.
For example, 192.168.1.1 becomes ::ffff:192.168.1.1 or ::ffff:c0a8:0101 in IPv6 format.
Mapping Types
IPv4-Mapped IPv6 Address
Format: ::ffff:IPv4
Used for communication between IPv6-only hosts and IPv4 hosts.
- ::ffff:192.168.1.1 (mixed notation)
- ::ffff:c0a8:0101 (full hex notation)
IPv4-Compatible IPv6 Address (Deprecated)
Format: ::IPv4
Older format, now deprecated in favor of mapped addresses.
Using the IPv4 to IPv6 API
TinyFn provides an endpoint for IPv4 to IPv6 mapping:
GET https://api.tinyfn.io/v1/ip/ipv4-to-ipv6?ip=192.168.1.1
Headers: X-API-Key: your-api-key
{
"ipv4": "192.168.1.1",
"ipv6_mapped": "::ffff:192.168.1.1",
"ipv6_mapped_full": "::ffff:c0a8:0101",
"ipv6_expanded": "0000:0000:0000:0000:0000:ffff:c0a8:0101",
"ipv6_compatible": "::192.168.1.1"
}
Parameters
| Parameter | Type | Description |
|---|---|---|
ip |
string | IPv4 address to map (required) |
format |
string | Output format: "mixed", "full", "expanded" (default: "mixed") |
Code Examples
JavaScript / Node.js
const response = await fetch(
'https://api.tinyfn.io/v1/ip/ipv4-to-ipv6?ip=192.168.1.1',
{ headers: { 'X-API-Key': 'your-api-key' } }
);
const { ipv6_mapped } = await response.json();
console.log(ipv6_mapped); // "::ffff:192.168.1.1"
Python
import requests
response = requests.get(
'https://api.tinyfn.io/v1/ip/ipv4-to-ipv6',
headers={'X-API-Key': 'your-api-key'},
params={'ip': '192.168.1.1'}
)
ipv6 = response.json()['ipv6_mapped']
print(ipv6) # "::ffff:192.168.1.1"
cURL
curl "https://api.tinyfn.io/v1/ip/ipv4-to-ipv6?ip=192.168.1.1" \
-H "X-API-Key: your-api-key"
Common Use Cases
- Dual-Stack Applications: Support both IPv4 and IPv6 in single codebase
- Socket Programming: Use IPv6 sockets that accept IPv4 connections
- Database Storage: Store all IPs in unified IPv6 format
- Migration Planning: Prepare for IPv4 to IPv6 transition
- Logging Standardization: Consistent IP format in logs
Best Practices
- Use mapped format: ::ffff: prefix is the standard for dual-stack
- Store in IPv6 format: Modern systems should use IPv6-native storage
- Display appropriately: Show mixed notation for human readability
- Handle both formats: Accept both IPv4 and IPv6 inputs in your applications
Use via MCP
Your AI agent can call this tool directly via Model Context Protocol — no HTTP code needed. Add TinyFn to Claude Desktop, Cursor, or any MCP client:
{
"mcpServers": {
"tinyfn-ip": {
"url": "https://api.tinyfn.io/mcp/ip/",
"headers": {
"X-API-Key": "your-api-key"
}
}
}
}
See all ip address tools available via MCP in our IP Address MCP Tools for AI Agents guide.
Try the IPv4 to IPv6 API
Get your free API key and start mapping IP addresses in seconds.
Get Free API Key