Loading Techie Utils…

Semver Range Checker

Test versions against npm ranges, sort them by precedence, and see what each bump produces. Free, and runs entirely in your browser — nothing is uploaded.

About Semver Checker

Semantic versioning puts meaning in the three numbers: MAJOR breaks things, MINOR adds things, PATCH fixes things. A range in package.json says which of those changes a project accepts. The ranges are compact, and it is easy to misread them.

The ranges are expanded to what they actually allow. ^1.2.3 means at least 1.2.3 and below 2.0.0. ^0.2.3 means below 0.3.0, because below 1.0 the minor version is treated as the breaking one. ~1.2 means below 1.3.0. The comparators are shown the way npm stores them, and each set is also described in words.

The rule that catches everyone is prereleases. 2.0.0-beta.1 does not satisfy >=1.0.0, even though it is numerically higher, because npm only installs a prerelease when the range names a prerelease of that same release. The result says when that is why a version was excluded. Sorting follows semver precedence, so 1.10.0 comes after 1.9.0, and bumping shows what npm version would produce.

Where it helps

  • Follows node-semver's grammar: caret, tilde, x-ranges, hyphen ranges, comparator sets and || alternatives.
  • Applies npm's prerelease rule, and says when a prerelease was excluded because of it.
  • Shows the expanded comparators and a plain description, which settles what a range really accepts.
  • Sorts by precedence, with numeric and alphanumeric prerelease identifiers compared the way the specification says.
  • Shows what every npm version bump would produce, including the pre bumps with a label.

Limits

  • It follows npm's rules. Cargo, Composer and other ecosystems read some operators differently: a bare version in Cargo means a caret range, for example.
  • It checks the versions you give it, and does not look up which versions of a package have been published.

Frequently asked questions

What is the difference between ^ and ~?

Caret allows any change that does not alter the leftmost non-zero number, so ^1.2.3 allows 1.x. Tilde allows only patch changes when a minor version is given, so ~1.2.3 allows 1.2.x. Below 1.0 the caret narrows: ^0.2.3 allows only 0.2.x.

Why doesn't my prerelease satisfy the range?

npm lets a prerelease through only when a comparator in the same set names a prerelease of the same major.minor.patch. >=1.0.0 does not match 2.0.0-beta.1, but >=2.0.0-beta.0 does. This stops a range from quietly installing unstable versions. Turn on Include prereleases to see what would match if they were allowed.

What does the -0 in <2.0.0-0 mean?

It is the lowest possible prerelease of 2.0.0. Writing the upper bound this way means below 2.0.0 and below every prerelease of 2.0.0, so ^1.2.3 cannot let in 2.0.0-alpha.

Does build metadata such as +build.5 matter?

Not for ordering. The specification says build metadata is ignored for precedence, so 1.0.0+a and 1.0.0+b are equal. It is kept in the version string for information only.

Related tools

More Web Development tools