SemVer range checker
Explain an npm-style semantic version range (^, ~, x, hyphen ranges and ||) in plain English and test versions against it, with the reason each one matches or not, including how prereleases are handled. Same rules as npm. Runs in your browser.
Last updated
What it does
- Explains a semantic version range in plain English and shows the comparators it expands to:
^1.2.3is>=1.2.3 <2.0.0-0, which means 1.2.3 or later, below 2.0.0. - Tests a list of versions against it and says why each one matches or doesn't: which comparator failed, or that a prerelease isn't allowed.
- Shows the lowest version the range can match and the highest and lowest matching versions in your list, like npm picks when installing.
- Uses npm's own
semverlibrary, so the result is the same as npm, pnpm and yarn. Options match npm's--include-prereleaseand loose parsing.
Range syntax in brief
^1.2.3(caret): allows changes that don't modify the left-most non-zero number:>=1.2.3 <2.0.0. Below 1.0.0 it narrows:^0.2.3is<0.3.0and^0.0.3is exactly 0.0.3.~1.2.3(tilde): patch updates only:>=1.2.3 <1.3.0.~1allows minor updates:<2.0.0.1.x,1.2.*and1(wildcards): any version in that line.1.2.3 - 2.3.4(hyphen): inclusive at both ends. A partial upper bound such as- 2.3means<2.4.0.a || b: matches if either side matches. Comparators separated by spaces must all match.
Questions
- Why doesn't ^1.2.3 match 1.3.0-beta.1?
- npm excludes prereleases unless the range names a prerelease of the same major.minor.patch, so users don't get unstable versions by accident.
^1.3.0-beta.0would match it, or turn on "Include prereleases". - What does <2.0.0-0 mean?
- It is how npm writes "below 2.0.0, and below any 2.0.0 prerelease too".
-0is the lowest possible prerelease, so 2.0.0-alpha doesn't sneak in. - Is v1.2.3 a valid version?
- Not strictly: semver is
MAJOR.MINOR.PATCH. npm accepts a leadingvor=and trims spaces in loose mode, and the checker suggests the cleaned-up version when one doesn't parse.