# is-cidr

> Check if a string is an IP address in CIDR notation

Latest version **7.0.1** (published 2026-07-28) · BSD-2-Clause license · 0 weekly downloads

## Install

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

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 7.0.1 |
| Published | 2026-07-28 |
| First published | 2016-03-25 |
| Weekly downloads | 0 |
| License | BSD-2-Clause |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22 |
| Dependencies | 1 |
| Unpacked size | 4.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| Author | silverwind <me@silverwind.io> |
| Maintainers | silverwind |
| Keywords | cidr, ip, ipv4, ipv6, subnet, network |

## Links

- npm: https://www.npmjs.com/package/is-cidr
- Repository: silverwind/is-cidr
- npm.io page: https://npm.io/package/is-cidr

## Dependencies (1)

- [cidr-regex](https://npm.io/package/cidr-regex.md) ^7.0.0

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 7.0.1 (latest) — 2026-07-28
- 7.0.0 — 2026-05-07
- 6.0.4 — 2026-04-21
- 6.0.3 — 2026-02-09
- 6.0.2 — 2026-01-24
- 6.0.1 — 2025-09-23
- 6.0.0 — 2025-08-01
- 5.1.1 — 2025-02-14
- 5.1.0 — 2024-05-23
- 5.0.5 — 2024-04-09
- 5.0.4 — 2024-04-08
- 5.0.3 — 2023-03-30
- 5.0.2 — 2022-09-20
- 5.0.1 — 2022-09-19
- 5.0.0 — 2022-09-16
- … 16 more at https://npm.io/package/is-cidr/versions

## README

# is-cidr
[![](https://img.shields.io/npm/v/is-cidr.svg?style=flat)](https://www.npmjs.org/package/is-cidr) [![](https://img.shields.io/npm/dm/is-cidr.svg)](https://www.npmjs.org/package/is-cidr) [![](https://packagephobia.com/badge?p=is-cidr)](https://packagephobia.com/result?p=is-cidr) [![](https://depx.co/api/badge/is-cidr)](https://depx.co/pkg/is-cidr)

> Check if a string is an IP address in CIDR notation

## Install

```
npm i is-cidr
```

## Usage

```js
import isCidr from "is-cidr";

isCidr("192.168.0.1/24"); //=> 4
isCidr("1:2:3:4:5:6:7:8/64"); //=> 6
isCidr("10.0.0.0"); //=> 0
isCidr.v6("10.0.0.0/24"); //=> false
```

## API
### isCidr(input)

Check if `input` is a IPv4 or IPv6 CIDR. Returns either `4`, `6` (indicating the IP version) or `0` if the string is not a CIDR.

### isCidr.v4(input)

Check if `input` is a IPv4 CIDR. Returns a boolean.

### isCidr.v6(input)

Check if `input` is a IPv6 CIDR. Returns a boolean.

## Related

- [ip-bigint](https://github.com/silverwind/ip-bigint) - Convert IPv4 and IPv6 addresses to native BigInt and vice-versa
- [ip-regex](https://github.com/sindresorhus/ip-regex) - Regular expression for matching IP addresses
- [is-ip](https://github.com/sindresorhus/is-ip) - Check if a string is an IP address
- [cidr-regex](https://github.com/silverwind/cidr-regex) - Check if a string is an IP address in CIDR notation
- [cidr-tools](https://github.com/silverwind/cidr-tools) - Tools to work with IPv4 and IPv6 CIDR network lists

## License

© [silverwind](https://github.com/silverwind), distributed under BSD licence

Based on previous work by [Felipe Apostol](https://github.com/flipjs)

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