Skip to content

Utils / Full Stack / isValidIPv6

Function: isValidIPv6()

ts
function isValidIPv6(ip): boolean;

Parameters

ParameterTypeDescription

ip

string

The string to validate as an IPv6 address.

Returns

boolean

true if the string is a valid IPv6 address, otherwise false.

Deprecated

Use isValidIP(ip, { version: 6 }) instead. This function will be removed in a future major version.

See

isValidIP

(Deprecated) Validates if the given string is a valid IPv6 address.

An IPv6 address is a 128-bit address represented as eight groups of four hexadecimal digits, separated by colons. Shortened notation and mixed IPv4/IPv6 formats are also supported.

Example

typescript
// Prefer the new way:
isValidIP("2001:0db8:85a3:0000:0000:8a2e:0370:7334", { version: 6 }); // true
// Legacy:
isValidIPv6("2001:0db8:85a3:0000:0000:8a2e:0370:7334"); // true
isValidIPv6("1234::abcd"); // true
isValidIPv6("localhost"); // false

Version v1.33.1 - Built on 2026-03-28