Skip to main content
AllDevToolsHub
Back to all patterns

IPv6 Address Validation

Web & Network

Validates a full (non-compressed) IPv6 address in colon-hexadecimal notation.

/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/

How it works

A full IPv6 address consists of eight groups of four hexadecimal digits separated by colons. This pattern validates the full form only, it does not handle compressed notation (::) or mixed IPv4/IPv6 addresses. For production use, prefer a library.

Test Cases

Should Match

  • 2001:0db8:85a3:0000:0000:8a2e:0370:7334
  • fe80:0000:0000:0000:0202:b3ff:fe1e:8329

Should NOT Match

  • ::1
  • 2001:db8::1
  • 192.168.1.1

Quick Summary

Validates full-form IPv6 addresses (8 groups of 4 hex digits separated by colons). Does not handle compressed :: notation. Use a dedicated IP library for full RFC 4291 compliance.

Key Takeaways

Key Takeaways

  • Only matches full-form IPv6, 8 groups of 1–4 hex digits separated by colons
  • Does not match compressed notation like ::1 or 2001:db8::1
  • Does not match IPv4-mapped IPv6 addresses like ::ffff:192.168.1.1
  • For full IPv6 validation including compression, use a library like 'is-ip' or 'ipaddr.js'
Use Cases

When to use it

  • Validating IPv6 addresses in network configuration tools
  • Parsing full-form IPv6 from structured data files
  • Quick format check before passing to a network library
Watch out

Common Mistakes

  • Expecting this to match ::1 (loopback), it won't; compressed form needs a different pattern
  • Using this in production without handling compressed IPv6, most real-world IPv6 uses compression
FAQ

IPv6 Address Validation, Frequently Asked

How do I validate compressed IPv6 like ::1?

Compressed IPv6 validation is complex. Use a library like 'ipaddr.js' or 'is-ip' in Node.js for full RFC 4291 support.

What is the difference between IPv4 and IPv6?

IPv4 uses 32-bit addresses (4 billion total); IPv6 uses 128-bit addresses (340 undecillion total), solving address exhaustion.