Semver Range Tester
Test if versions satisfy semver ranges with visual explanation of what matches
^1.2.3 matches >=1.2.3 and <2.0.0
{
"dependencies": {
"example-package": "^1.2.3"
}
}Caret (^): Default for npm install. Allows changes that do not modify the left-most non-zero digit.
Tilde (~): Allows patch-level changes. ~1.2.3 matches >=1.2.3 <1.3.0.
Wildcards: *, x, 1.x, 1.2.x match any value in that position.
OR / AND: Use || for alternatives, spaces or && for intersection.
Hyphen: 1.0.0 - 2.0.0 is equivalent to >=1.0.0 <=2.0.0.
| Range | Meaning | Example Match |
|---|---|---|
| ^1.2.3 | >=1.2.3 <2.0.0 | 1.9.9 |
| ~1.2.3 | >=1.2.3 <1.3.0 | 1.2.9 |
| >=1.0.0 | 1.0.0 and above | 5.0.0 |
| >1.0.0 <2.0.0 | Between (exclusive) | 1.5.0 |
| 1.2.x | >=1.2.0 <1.3.0 | 1.2.7 |
| * | Any version | 99.0.0 |
| 1.0.0 - 2.0.0 | >=1.0.0 <=2.0.0 | 1.5.0 |
| ^0.2.3 | >=0.2.3 <0.3.0 | 0.2.9 |
| >=1.0.0 || >=2.0.0 | Either range | 1.0.0, 2.5.0 |
Semantic Versioning (semver) uses MAJOR.MINOR.PATCH format with specific range operators to define compatible version sets. This tool tests whether a version matches a range expression — the same logic npm, Yarn, and Cargo use to resolve dependencies.
Range Operators
- ^1.2.3 (caret):
>=1.2.3 <2.0.0— Allows minor and patch updates. The default when younpm install. - ~1.2.3 (tilde):
>=1.2.3 <1.3.0— Allows only patch updates. More conservative. - >=1.0.0 <2.0.0: Explicit range with comparison operators.
- 1.2.x or 1.2.*: Wildcard — any patch version of 1.2.
- 1.2.3 - 2.3.4: Hyphen range — inclusive on both ends.
- ^1.0.0 || ^2.0.0: OR — matches either range.
Caret (^) Edge Cases
The caret operator has special behavior for versions below 1.0.0:
^0.2.3=>=0.2.3 <0.3.0(minor is treated as breaking)^0.0.3=>=0.0.3 <0.0.4(patch is treated as breaking)
This catches a common source of confusion in npm dependency management.
Pre-release Versions
Pre-release versions like 1.0.0-alpha.1 only match ranges that explicitly include pre-release tags on the same [major, minor, patch] tuple. For example, >=1.0.0-alpha.1 matches 1.0.0-alpha.2 but >=1.0.0 does not match 1.0.1-alpha.1.
Use Cases
- Dependency debugging: Understand why npm installs a specific version
- Package publishing: Verify your version satisfies consumers’ range requirements
- CI/CD pipeline configuration: Test version constraints before deployment