Skip to content
xt-tools

Semver calculator

Sort and compare semantic versions, test them against npm-style ranges and compute the next version.

npm syntax: ^, ~, x ranges, hyphen ranges, comparators and ||.

Let ranges match any prerelease.

Accept =1.2.3, 1.2.3beta…

Try:

Range

Normalized range
>=1.2.0 <2.0.0-0||>=2.1.0 <3.0.0-0
AlternativesA version must match one of them.
>=1.2.0 <2.0.0-0 || >=2.1.0 <3.0.0-0
Lowest possibleThe smallest version that could ever match.
1.2.0
Satisfying
4 of 6 versions
Highest satisfying
2.1.0
Lowest satisfying
1.2.3
Versions and whether they satisfy the range
InputVersionKindSatisfies range
0.9.00.9.0ReleaseNo
1.2.31.2.3ReleaseYes
1.2.101.2.10ReleaseYes
1.10.01.10.0ReleaseYes
v2.0.0-beta.12.0.0-beta.1PrereleaseNo
2.1.02.1.0ReleaseYes

Compare two versions

1.2.3 is lower than 1.3.0-rc.1 (1.2.3 < 1.3.0-rc.1). Difference: preminor (the minor number differs and one of them is a prerelease).

Increment a version

Next major
2.0.0
Next minor
1.3.0
Next patch
1.2.4
Pre-major
2.0.0-beta.0
Pre-minor
1.3.0-beta.0
Pre-patch
1.2.4-beta.0
Next prerelease
1.2.4-beta.0

Uses the semver package (ISC), the same version logic as npm.