Tools

Semver range checker

See which versions a range like ^1.2.0 or ~2.3 accepts — with npm's own node-semver, pre-releases and all.

Runs in your browserCode converters5.5K
Free

Input

0 B

Result

The result will appear here.

Whether ^1.2.0 accepts 1.10.0-beta.1, or what ^0.2.3 allows, is easy to guess wrong and awkward to test. Paste a list of versions and a range, and this tool marks each version as accepted or rejected using node-semver, the library npm itself resolves dependencies with. It also sorts the versions correctly — 1.10.0 after 1.2.0, pre-releases before their release — shows the range written out in full, and names the highest and lowest versions that satisfy it.

How it works

  • Versions can be separated by commas, spaces or new lines; anything that is not a valid version, such as latest, is listed separately rather than silently ignored.
  • The range is shown in its expanded form — ^1.2.0 is >=1.2.0 <2.0.0-0 — which is what node-semver actually compares against.
  • Pre-releases are excluded unless you allow them, matching npm: by default ^1.2.0 does not accept 1.10.0-beta.1.
  • The next patch, minor, major and rc pre-release of the highest version are worked out, and with exactly two versions the difference between them (major, minor, patch…) is shown.

Where your data goes

Nowhere. This tool runs entirely in your browser: the text you paste is processed by the page and is never transmitted to a server or written to a log.

This tool is free and needs no account. Its results exist only in your open page and are not saved anywhere.

What it costs

This tool is free, with no sign-in and no points.

Common questions

What is the difference between ^ and ~?
^ allows anything that does not change the leftmost non-zero number: ^1.2.3 accepts up to but not including 2.0.0. ~ only allows patch updates when a minor version is given: ~1.2.3 accepts up to but not including 1.3.0. npm writes ^ into package.json by default.
Why does ^0.2.3 not accept 0.3.0?
Because for 0.x versions the minor number is treated as the breaking one: before 1.0.0, semantic versioning makes no stability promise, so ^0.2.3 means >=0.2.3 <0.3.0. Likewise ^0.0.3 accepts only 0.0.3 itself.
Why is 1.10.0-beta.1 rejected by ^1.2.0?
npm keeps pre-releases out of ranges unless the range itself names a pre-release of the same major.minor.patch. That stops a beta from being installed by accident. Turn on include pre-releases to see what the range would accept if they were allowed, which is how npm behaves with --include-prerelease.
What does loose mode do?
It accepts sloppy versions that strict semver rejects, such as =1.2.3beta, and shows what they were read as — 1.2.3-beta in this case. Old packages and some tags use such versions; strict mode is what the specification allows.

The open-source behind it

This tool runs on npm/node-semver, released under ISC. If you need the same behaviour inside your own program, that is the library to reach for.

npm/node-semver

Also known as

  • semver checker
  • semver range calculator
  • npm version range
  • caret vs tilde version
  • semver satisfies
  • semantic versioning calculator