Skip to content
MoneyDeck

Semver Range Checker

Test which versions satisfy an npm semver range, and compare versions

Updated · Free, no signup

Highest matching version

1.9.9

Matching versions

1.2.3
1.2.10
1.3.0
1.9.9

Versions that match

4

Valid versions tested

8

Range as primitive comparators

>=1.2.3 <2.0.0-0

Comparison of A and B

1.10.0 > 1.9.0 (minor difference)

Next versions after A

patch → 1.10.1 · minor → 1.11.0 · major → 2.0.0
  • Prerelease versions only match a range that itself names a prerelease on the same major.minor.patch, e.g. >=1.5.0-rc.0.
  • 4 of 8 valid versions satisfy ^1.2.3; npm would install 1.9.9 from this list.

Each version against the range

VersionResult
1.2.2✗ outside range
1.2.3✓ satisfies
1.2.10✓ satisfies
1.3.0✓ satisfies
1.5.0-rc.1✗ (prerelease excluded)
1.9.9✓ satisfies
2.0.0-beta.1✗ outside range
2.0.0✗ outside range

About the Semver Range Checker

This semver range checker shows exactly which versions an npm-style semantic versioning range accepts. Enter a range such as ^1.2.3, ~0.4.1, 1.x, >=2.0.0 <3.0.0 or 1.2.3 - 2.3.4 and a list of versions, and it marks each one as matching or not, picks the highest version that satisfies the range, and expands the range into the primitive comparators npm uses internally.

It is useful when you are writing package.json dependencies, debugging why npm, Yarn or pnpm installed a particular version, or deciding whether a caret or tilde range is the right level of trust in an upstream package. The caret rules for 0.x versions and the treatment of prerelease tags (1.5.0-beta.1) catch many people out, and the tool applies them the same way node-semver does.

A second panel compares any two versions using semver precedence — so 1.10.0 is correctly newer than 1.9.0 — and shows what the next patch, minor and major versions would be.

How to use the semver range checker

  1. 1Type the range exactly as it appears in package.json, e.g. ^1.2.3.
  2. 2Paste the versions you want to test, one per line (for example from npm view <pkg> versions).
  3. 3Read the highest matching version — the one npm would pick from that list.
  4. 4Check the expanded comparators to understand the real lower and upper bounds.
  5. 5Optionally compare two versions and preview the next patch, minor and major numbers.

Formula and method

^M.m.p → >=M.m.p <(M+1).0.0-0 (M>0) · ~M.m.p → >=M.m.p <M.(m+1).0-0 · M.x → >=M.0.0 <(M+1).0.0-0

A semantic version is MAJOR.MINOR.PATCH with an optional prerelease (-beta.1) and build metadata (+sha). Versions are ordered by major, then minor, then patch as numbers; a prerelease ranks below the same release, and prerelease identifiers compare numerically when both are numbers and in ASCII order otherwise. Build metadata is ignored.

A range is one or more comparator sets joined by ||; a version must satisfy every comparator in at least one set. Caret, tilde, x-ranges and hyphen ranges are first expanded into plain comparators: the caret allows changes that do not modify the left-most non-zero part, the tilde allows patch-level changes when a minor is given, and the upper bounds end in -0 so prereleases of the next version are excluded. Finally, a prerelease version only matches if some comparator in the same set has a prerelease on the same major.minor.patch — exactly as npm's node-semver behaves by default.

M, m, p
Major, minor and patch numbers
-0
Lowest possible prerelease, used to exclude prereleases at the upper bound
||
Logical OR between comparator sets

Worked examples

Caret range ^1.2.3

^1.2.3 accepts anything from 1.2.3 up to but not including 2.0.0. Of the eight versions, 1.2.3, 1.2.10, 1.3.0 and 1.9.9 match; 1.5.0-rc.1 is a prerelease, so it is excluded even though it sits inside the bounds, and 2.0.0-beta.1 is above the <2.0.0-0 upper bound. npm would choose 1.9.9.

Tilde range ~1.2.3

A tilde with a full version only allows patch updates, so ~1.2.3 means >=1.2.3 <1.3.0. Only 1.2.3 and 1.2.10 qualify, and the highest is 1.2.10.

Caret on a 0.x version

Below 1.0.0 the caret treats the minor number as breaking, so ^0.2.3 is >=0.2.3 <0.3.0. Only 0.2.3 and 0.2.9 match; 0.3.0 would be considered a breaking release.

Union with a prerelease

The first set names a 1.5.0 prerelease, so 1.5.0-rc.1 is allowed there, along with 1.5.0. The 2.x set matches 2.4.1 but not 2.0.0-beta.1. A prerelease ranks below its release, and bumping 2.0.0-beta.1 at any level yields 2.0.0.

Frequently asked questions

What is the difference between ^ and ~ in package.json?+

The caret (^1.2.3) allows minor and patch updates: >=1.2.3 <2.0.0. The tilde (~1.2.3) allows only patch updates: >=1.2.3 <1.3.0. npm uses the caret by default when you run npm install <package>.

Why does ^0.2.3 not install 0.3.0?+

For versions below 1.0.0 the caret treats the first non-zero number as the major version. ^0.2.3 therefore means >=0.2.3 <0.3.0, and ^0.0.3 means exactly >=0.0.3 <0.0.4.

Why does my range not match a beta or rc version?+

By default npm excludes prerelease versions unless the range itself mentions a prerelease of the same major.minor.patch. ^1.5.0 will never select 1.6.0-beta.1, but >=1.6.0-beta.0 will.

Is 1.10.0 newer than 1.9.0?+

Yes. Semver compares each part as a number, not as text, so minor version 10 is greater than 9. String sorting would wrongly put 1.10.0 before 1.9.0.

What does a range like 1.2.3 - 2.3.4 mean?+

A hyphen range is inclusive: >=1.2.3 <=2.3.4. If the right side is partial, such as 1.2.3 - 2.3, it becomes >=1.2.3 <2.4.0-0, accepting every 2.3.x release.

Related tools