Check if a string is an IP address
If you only need this for Node.js and don't care about browser support, you may want to use net.isIP instead. Note that it returns an integer instead of a boolean.
npm install is-ip
import {isIP, isIPv4} from 'is-ip';
isIP('1:2:3:4:5:6:7:8');
//=> true
isIP('192.168.0.1');
//=> true
isIPv4('1:2:3:4:5:6:7:8');
//=> false
Check if string is IPv6 or IPv4.
Check if string is IPv6.
Check if string is IPv4.
Returns 6 if string is IPv6, 4 if string is IPv4, or undefined if string is neither.
import {ipVersion} from 'is-ip';
ipVersion('1:2:3:4:5:6:7:8');
//=> 6
ipVersion('192.168.0.1');
//=> 4
ipVersion('abc');
//=> undefined
Overall
Maintained
Code review
npm
Latest release
Releases this year
2,635 followers · starred Jun 2024
97 followers · starred Feb 2020
Check if a string is an IP address
If you only need this for Node.js and don't care about browser support, you may want to use net.isIP instead. Note that it returns an integer instead of a boolean.
npm install is-ip
import {isIP, isIPv4} from 'is-ip';
isIP('1:2:3:4:5:6:7:8');
//=> true
isIP('192.168.0.1');
//=> true
isIPv4('1:2:3:4:5:6:7:8');
//=> false
Check if string is IPv6 or IPv4.
Check if string is IPv6.
Check if string is IPv4.
Returns 6 if string is IPv6, 4 if string is IPv4, or undefined if string is neither.
import {ipVersion} from 'is-ip';
ipVersion('1:2:3:4:5:6:7:8');
//=> 6
ipVersion('192.168.0.1');
//=> 4
ipVersion('abc');
//=> undefined
Overall
Maintained
Code review
npm
Latest release
Releases this year
2,635 followers · starred Jun 2024
97 followers · starred Feb 2020