How to use the semver range tester
- Enter a version range, such as ^1.2.3 or >=1.0.0 <2.0.0.
- Enter a list of versions to test, one per line or separated by spaces or commas.
- Tick Let prerelease versions match any range if you want versions such as 2.0.0-rc.1 to count.
- Read which versions match, the highest and lowest match and the range rewritten as plain comparators.
Formula
^1.2.3 means >=1.2.3 <2.0.0-0
~1.2.3 means >=1.2.3 <1.3.0-0
1.2.x means >=1.2.0 <1.3.0-0
1.2.3 - 2.3.4 means >=1.2.3 <=2.3.4
a || b matches a version that satisfies a or b
Versions compare by major, minor and patch as numbers. A prerelease sorts below its release, and its identifiers are compared one by one. The -0 on an upper bound keeps prereleases of that version out.
Which of eight versions fit a caret range
The versions 0.9.9, 1.0.0, 1.2.3, 1.2.4-beta.1, 1.9.0, 2.0.0, 2.0.0-rc.1 and 3.1.4 are tested against ^1.2.3, which is >=1.2.3 <2.0.0-0. Only 1.2.3 and 1.9.0 match, so the answer is 2 of 8, with 1.9.0 the highest. The prerelease 1.2.4-beta.1 is left out, because the range names no prerelease of 1.2.4.
The tilde range ~1.2.3 matches only 1.2.3. The range >=1.0.0 <1.5.0 || >=2.0.0 matches 1.0.0, 1.2.3, 2.0.0 and 3.1.4. With the prerelease box ticked and the range ^1.2.3-beta.0, the version 1.2.4-beta.1 matches as well, giving 3 of 8.
Caret, tilde and x-ranges
A caret allows changes that keep the left-most non-zero part the same: ^1.2.3 allows any 1.x.y from 1.2.3, ^0.2.3 allows 0.2.x from 0.2.3, and ^0.0.3 allows only 0.0.3. A tilde allows patch changes only when a minor version is given, so ~1.2.3 stays within 1.2.x. An x or star stands for any number, so 1.x means any 1.y.z.
These rules explain why a package that says ^1.2.3 can quietly move to 1.9.0 when you install, but never to 2.0.0.
Prereleases and other tools
By default, a prerelease version satisfies a range only if some comparator in the same alternative names a prerelease of the same major, minor and patch. That keeps unstable builds out of normal installs. The checkbox switches that rule off. To compare two exact versions, or sort a list, use the Semantic Version Comparator. To check the file where a range is written, use the JSON Formatter and Validator.
Assumptions and limits
- The syntax is the one npm uses. Other package managers differ in small ways.
- Versions need all three numbers, such as 1.2.0. A short form like 2.0 is reported as not valid.
- Build metadata after a plus sign is ignored when comparing.
- At most 300 versions are tested at a time.
- The range and versions shown when the page opens are examples.
Frequently asked questions
What does the -0 at the end of an upper bound mean?
It is the lowest possible prerelease. Writing <2.0.0-0 excludes 2.0.0 and every prerelease of 2.0.0, such as 2.0.0-beta, while allowing everything below.
Why does 1.2.4-beta.1 not match ^1.2.3?
Prerelease versions are left out unless the range names a prerelease of the same version. Tick the prerelease box to include them.
How do I match any version?
Use a star or the letter x. Both mean any version, and the page shows them as a star. Prereleases are still left out unless you tick the box.
Does the page check that a version exists in a registry?
No. It only compares the text you enter with the range. It never contacts a registry or sends your versions anywhere.