# is-ip

> Check if a string is an IP address

Latest version **5.0.1** (published 2023-08-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install is-ip
pnpm add is-ip
yarn add is-ip
bun add is-ip
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.0.1 |
| Published | 2023-08-05 |
| First published | 2014-09-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=14.16 |
| Dependencies | 2 |
| Unpacked size | 4.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 118 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | ip, ipv6, ipv4, regex, regexp, match, test, find, text, pattern, internet, protocol, address, validate, detect, check, is, string |

## Links

- npm: https://www.npmjs.com/package/is-ip
- Repository: https://github.com/sindresorhus/is-ip
- Homepage: https://github.com/sindresorhus/is-ip#readme
- Issues: https://github.com/sindresorhus/is-ip/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/is-ip

## Dependencies (2)

- [ip-regex](https://npm.io/package/ip-regex.md) ^5.0.0
- [super-regex](https://npm.io/package/super-regex.md) ^0.2.0

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 5.0.1 (latest) — 2023-08-05
- 5.0.0 — 2022-07-22
- 4.0.0 — 2022-01-01
- 3.1.0 — 2019-06-19
- 3.0.0 — 2019-04-17
- 2.0.0 — 2017-01-09
- 1.0.0 — 2014-09-06

## README

# is-ip

> 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`](https://nodejs.org/api/net.html#net_net_isip_input) instead. Note that it returns an integer instead of a boolean.

## Install

```sh
npm install is-ip
```

## Usage

```js
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
```

## API

### isIP(string)

Check if `string` is IPv6 or IPv4.

### isIPv6(string)

Check if `string` is IPv6.

### isIPv4(string)

Check if `string` is IPv4.

### ipVersion(string)

Returns `6` if `string` is IPv6, `4` if `string` is IPv4, or `undefined` if `string` is neither.

```js
import {ipVersion} from 'is-ip';

ipVersion('1:2:3:4:5:6:7:8');
//=> 6

ipVersion('192.168.0.1');
//=> 4

ipVersion('abc');
//=> undefined
```

## Related

- [ip-regex](https://github.com/sindresorhus/ip-regex) - Regular expression for matching IP addresses
- [is-cidr](https://github.com/silverwind/is-cidr) - Check if a string is an IP address in CIDR notation
- [cidr-regex](https://github.com/silverwind/cidr-regex) - Regular expression for matching IP addresses in CIDR notation

---
_Source: https://npm.io/package/is-ip · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
