ZapKit

Semver calculator

Work out the next version number, compare two versions correctly, and check whether a version satisfies a dependency range.

What is semantic versioning?

Semantic versioning, or semver, is the version numbering scheme used by npm, Cargo, Composer and most libraries. The three numbers signal what kind of change a release contains, so package managers can safely update dependencies within a range.

Enter a version to see its parts and the next major, minor, patch and pre-release versions, using the label you choose. Optionally compare it with another version, and test it against an npm-style range with carets, tildes, wildcards, comparators, hyphen ranges and ||.

How to use the Semver calculator

  1. 1.Enter a version

    Like 1.4.2 or 2.0.0-rc.1.

  2. 2.Compare and check a range

    Both optional.

  3. 3.Read the next versions

    Major, minor, patch and pre-release.

Example: a beta release

Version 2.4.1-beta.3, label beta:

Next pre-release / patch
2.4.1-beta.4 / 2.4.1
Next minor / major
2.5.0 / 3.0.0
Compared with 2.4.0
newer
In ^2.4.0-beta.1?
No: that range only includes betas of 2.4.0

Releasing the fix as 2.4.1 is the next step once the beta passes.

The rules

Versions are major.minor.patch: bump major for breaking changes, minor for new features and patch for fixes. Pre-releases like 1.0.0-beta.2 sort before 1.0.0, numeric parts compare as numbers (beta.11 is after beta.2), and build metadata after + is ignored when comparing.

Ranges follow npm: ^1.2.0 allows anything below 2.0.0, ~1.2.0 anything below 1.3.0, and 1.x any 1.y.z; for 0.x versions ^ is stricter. A pre-release only satisfies a range that names a pre-release of the same version, so ^2.4.0 won't pull in 2.4.1-beta.3. That rule keeps unfinished releases out of projects that only asked for stable versions.

Frequently asked questions

What does bumping a pre-release do?

It increments the last number, so beta.3 becomes beta.4, or starts a new label at 0.

Why does major go from 2.4.1-beta.3 to 3.0.0?

The pre-release belongs to 2.4.1, so the next breaking release is 3.0.0.

Does it support ||?

Yes, as in ^1.0.0 || ^2.0.0.

Is v1.2.3 accepted?

Yes. A leading v is ignored.

More Developer tools