Skip to content

Compare semantic versions, test ranges like ^1.2.3 and ~1.2, and compute the next version.

Loading tool

About Semver Calculator

Works with semantic versions using the same semver library npm uses. It tests a list of versions against an npm-style range (^, ~, x-ranges, hyphen ranges, comparators and ||) and explains the range, compares two versions, computes the next major, minor, patch or pre-release version, and sorts a list of versions, cleaning or coercing loose input like v1.2.3 or 1.2. Options cover loose parsing and including pre-releases in range matching.

Common uses

  • Check which versions a dependency range in package.json allows
  • Find the next version number for a release
  • Sort a list of version tags correctly instead of alphabetically
  • Understand why a pre-release does or does not match a range

FAQ

What is the difference between ^ and ~ in package.json?
^1.2.3 allows updates that do not change the left-most non-zero part, so >=1.2.3 <2.0.0. ~1.2.3 allows only patch updates, so >=1.2.3 <1.3.0.
How does ^ work for 0.x versions?
For versions below 1.0.0 the caret is stricter: ^0.2.3 means >=0.2.3 <0.3.0, and ^0.0.3 means >=0.0.3 <0.0.4.
Why doesn't my pre-release version match a range?
By default, pre-releases like 2.0.0-beta.1 only match a range if a comparator in it has a pre-release on the same major.minor.patch. Enabling 'include pre-releases' changes this.
Does build metadata affect version precedence?
No. In SemVer 2.0.0, build metadata after a + (for example 1.0.0+build.7) is ignored when comparing versions.