TCP
net.isIPv6()
Checks IPv6 literal syntax, including compressed notation. A valid IPv6 literal does not imply it is a safe destination. Tested on Node.js 22.16.0. Example output (one line per entry): ["true false"].
Formal Syntax & Structure
nodejs syntaxnodejs
net.isIPv6(input)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| input | string | Address candidate. |
Return Value
boolean
Whether input is IPv6.
Working Example
Example Snippetnodejs
import { isIPv6 } from 'node:net';console.log(isIPv6('2001:db8::1'), isIPv6('2001:::1'));