Need to validate IPv6 addresses in your application? This guide covers everything you need to know about IPv6 validation via API, including address formats, compression rules, and implementation examples.
What is IPv6?
IPv6 (Internet Protocol version 6) is the latest version of the Internet Protocol, designed to replace IPv4. IPv6 addresses are 128 bits long, written as eight groups of four hexadecimal digits.
For example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
IPv6 Address Formats
IPv6 addresses can be written in several formats:
Full Format
2001:0db8:85a3:0000:0000:8a2e:0370:7334 - All 8 groups, leading zeros included.
Compressed Format
2001:db8:85a3::8a2e:370:7334 - Leading zeros omitted, consecutive zero groups replaced with ::.
Loopback and Special
::1 (loopback), :: (unspecified), fe80:: (link-local).
Using the IPv6 Validator API
TinyFn provides a simple endpoint to validate IPv6 addresses:
GET https://api.tinyfn.io/v1/validate/ipv6?address=2001:db8:85a3::8a2e:370:7334
Headers: X-API-Key: your-api-key
{
"address": "2001:db8:85a3::8a2e:370:7334",
"valid": true,
"expanded": "2001:0db8:85a3:0000:0000:8a2e:0370:7334",
"compressed": "2001:db8:85a3::8a2e:370:7334",
"type": "global",
"scope": "global unicast"
}
Parameters
| Parameter | Type | Description |
|---|---|---|
address |
string | The IPv6 address to validate |
Code Examples
JavaScript / Node.js
// Validate IPv6 address
const response = await fetch(
'https://api.tinyfn.io/v1/validate/ipv6?address=2001:db8:85a3::8a2e:370:7334',
{ headers: { 'X-API-Key': 'your-api-key' } }
);
const { valid, expanded, type } = await response.json();
console.log(`Valid: ${valid}`); // true
console.log(`Expanded: ${expanded}`); // 2001:0db8:85a3:0000:0000:8a2e:0370:7334
console.log(`Type: ${type}`); // global
// Validate loopback
const loopbackResponse = await fetch(
'https://api.tinyfn.io/v1/validate/ipv6?address=::1',
{ headers: { 'X-API-Key': 'your-api-key' } }
);
const loopback = await loopbackResponse.json();
console.log(loopback.type); // loopback
Python
import requests
# Validate IPv6 address
response = requests.get(
'https://api.tinyfn.io/v1/validate/ipv6',
params={'address': '2001:db8:85a3::8a2e:370:7334'},
headers={'X-API-Key': 'your-api-key'}
)
data = response.json()
print(f"Valid: {data['valid']}") # True
print(f"Expanded: {data['expanded']}") # 2001:0db8:85a3:0000:0000:8a2e:0370:7334
print(f"Type: {data['type']}") # global
# Validate invalid address
response = requests.get(
'https://api.tinyfn.io/v1/validate/ipv6',
params={'address': 'not-an-ipv6'},
headers={'X-API-Key': 'your-api-key'}
)
print(response.json()['valid']) # False
cURL
# Validate IPv6 address
curl "https://api.tinyfn.io/v1/validate/ipv6?address=2001:db8:85a3::8a2e:370:7334" \
-H "X-API-Key: your-api-key"
# Validate compressed address
curl "https://api.tinyfn.io/v1/validate/ipv6?address=::1" \
-H "X-API-Key: your-api-key"
Common Use Cases
- Input Validation: Validate user-entered IPv6 addresses in forms
- Network Configuration: Verify addresses in config files
- Firewall Rules: Validate addresses before adding to rules
- DNS Management: Verify AAAA record values
- Log Analysis: Parse and validate addresses in logs
Best Practices
- Store in consistent format: Use expanded or compressed consistently
- Validate before processing: Don't assume user input is valid
- Handle both IPv4 and IPv6: Support dual-stack applications
- Consider address types: Loopback, link-local, and global have different uses
Try the IPv6 Validator API
Get your free API key and start validating IPv6 addresses in seconds.
Get Free API Key