Semver range checker
Check whether a semantic version satisfies an npm-style range — instantly
and offline. It is for developers reasoning about a package.json dependency
range, debugging why an unexpected version installed, or learning how caret and
tilde actually behave.
How it works
The checker expands your range into a set of simple comparators following the node-semver rules, then tests the version against them:
- Caret
^1.2.0keeps the left-most non-zero field fixed →>=1.2.0 <2.0.0. - Tilde
~1.2allows patch-level changes →>=1.2.0 <1.3.0. - Wildcards
1.x,1.2.x,*expand to comparator pairs. - Hyphen ranges
1.2.3 - 2.3.4become>=1.2.3 <=2.3.4. - Comparators
>=1.0.0 <2.0.0are used directly; space means AND. - OR sets are joined with
||; the version satisfies the range if it matches any one set.
Pre-release tags are ordered per the spec: numeric identifiers rank below alphanumeric, and a version with no pre-release outranks one with.
Expanded examples
| Version | Range | Satisfies? | Why |
|---|---|---|---|
| 1.4.2 | ^1.2.0 | yes | 1.4.2 is ≥ 1.2.0 and < 2.0.0 |
| 2.0.0 | ^1.2.0 | no | 2.0.0 is not < 2.0.0 |
| 1.2.9 | ~1.2 | yes | 1.2.9 is ≥ 1.2.0 and < 1.3.0 |
| 1.3.0 | ~1.2 | no | 1.3.0 is not < 1.3.0 |
| 0.2.5 | ^0.2.0 | yes | Left-most non-zero is minor; cap is 0.3.0 |
| 0.2.0 | ^0.1.0 | no | ^0.1.0 expands to ≥0.1.0 <0.2.0 |
| 2.0.0-rc.1 | >=2.0.0 | no | Pre-release is less than the stable version |
The 0.x special case
For versions starting with 0., caret (^) behaves more strictly because
the major field is zero and cannot protect stability. The left-most non-zero
field becomes the pin point:
^0.1.0→>=0.1.0 <0.2.0(minor is pinned)^0.0.3→>=0.0.3 <0.0.4(patch is pinned)
This reflects the expectation that 0.x packages treat every minor version as potentially breaking.
Why pre-releases rarely satisfy ranges
2.0.0-rc.1 is semantically lower than 2.0.0. A range like >=1.0.0 <3.0.0
does not match 2.0.0-rc.1 unless the pre-release version is explicitly listed
in the range. This prevents a ^1.0.0 declaration from accidentally installing a
beta of the next major. To allow a specific pre-release, use
>=2.0.0-rc.1 <2.0.0 or add it explicitly with an || clause.
Common debugging scenarios
“Why did npm install a version I didn’t expect?”
Paste the version that installed and the range from package.json — the checker
shows exactly which comparator set matched it.
“Is my peer dependency range too broad?”
Test boundary versions like the highest patch of a previous major (e.g., 1.9.9)
against your range to see whether it accidentally accepts them.
“Does my range include the new beta?” Test the pre-release tag explicitly — the expanded comparator output shows you precisely why it does or does not satisfy the range.
The result shows whether the version matches and the expanded comparator set used, so the verdict is always transparent. Everything runs in your browser — no package registry is ever contacted.