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
| Input | Version | Kind | Satisfies range |
|---|---|---|---|
| 0.9.0 | 0.9.0 | Release | No |
| 1.2.3 | 1.2.3 | Release | Yes |
| 1.2.10 | 1.2.10 | Release | Yes |
| 1.10.0 | 1.10.0 | Release | Yes |
| v2.0.0-beta.1 | 2.0.0-beta.1 | Prerelease | No |
| 2.1.0 | 2.1.0 | Release | Yes |
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.