Work out the next version number, check which of two versions is newer, see exactly what an npm range like ^1.2.0 or ~1.4 allows, or sort a messy list of versions, all with the official SemVer 2.0.0 precedence rules.
Last updated:
What do you want to do?
Used by the pre* bump types, like npm version --preid
npm syntax: ^1.2.3, ~1.2, 1.x, >=1.0.0 <2.0.0, 1.0.0 - 1.5.0, joined with ||
Enter your values to see the result.
Advertisement
Advertisement
How to use the Semantic Version Calculator
Pick a task: bump, compare, range test or sort.
Type your version(s). A leading v (v1.2.3) is accepted; build metadata after + is kept but ignored for ordering.
For a bump, choose the bump type and, for pre-releases, a label like beta.
For a range, paste the range from package.json and the versions you want to test.
Read the result and the working, then copy it or download the table as CSV.
SemVer precedence in four rules
Compare MAJOR, MINOR and PATCH as numbers, left to right. The first difference decides: 2.0.0 > 1.99.99 and 1.10.0 > 1.9.0.
A pre-release ranks below its release: 1.0.0-rc.1 < 1.0.0.
Pre-release identifiers are compared one by one: numbers numerically (beta.2 < beta.11), words in ASCII order (alpha < beta < rc), and a number always ranks below a word.
More identifiers win when all earlier ones are equal: 1.0.0-alpha < 1.0.0-alpha.1. Build metadata after + never counts.
Full example order: 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0.
npm range cheat sheet
Range
Means
Allows, for example
^1.2.3
>=1.2.3 <2.0.0-0
1.2.3, 1.3.0, 1.99.0
^0.2.3
>=0.2.3 <0.3.0-0
0.2.3, 0.2.9 (not 0.3.0)
^0.0.3
>=0.0.3 <0.0.4-0
0.0.3 only
~1.2.3
>=1.2.3 <1.3.0-0
1.2.3, 1.2.10
~1
>=1.0.0 <2.0.0-0
1.0.0 to 1.x.x
1.2.x or 1.2
>=1.2.0 <1.3.0-0
1.2.0, 1.2.7
1.2.3 - 2.3
>=1.2.3 <2.4.0-0
1.2.3 up to 2.3.x
>1.2
>=1.3.0
1.3.0 and later
<=1.2
<1.3.0-0
anything up to 1.2.x
* or "" or x
any version
every stable release
A || B
A or B
^1.0.0 || ^2.0.0
Which number should I bump?
Change you made
Bump
1.4.2 becomes
Fixed a bug, no API change
patch
1.4.3
Added a feature, old code still works
minor
1.5.0
Removed or changed something users rely on
major
2.0.0
Testing the next major before release
premajor --preid=beta
2.0.0-beta.0
Another test build
prerelease
2.0.0-beta.1
Versions 0.y.z are for initial development: anything may change at any time, which is why the caret treats the first non-zero number as the "major" one. Release 1.0.0 once your public API is stable.
Frequently asked questions
What is semantic versioning?
Semantic Versioning (SemVer 2.0.0) writes versions as MAJOR.MINOR.PATCH. You increase MAJOR for incompatible API changes, MINOR for backwards-compatible features and PATCH for backwards-compatible bug fixes. Optional pre-release (-beta.1) and build (+sha.5114f85) parts can follow.
What is the difference between ^ and ~ in package.json?
The caret allows changes that do not modify the left-most non-zero number: ^1.2.3 means >=1.2.3 <2.0.0, but ^0.2.3 means >=0.2.3 <0.3.0. The tilde allows only patch updates when a minor is given: ~1.2.3 means >=1.2.3 <1.3.0.
Why is 1.10.0 newer than 1.9.0?
Each part is compared as a whole number, not as text. 10 is greater than 9, so 1.10.0 has higher precedence even though it would sort earlier alphabetically.
Is 1.0.0-rc.1 higher or lower than 1.0.0?
Lower. A pre-release version ranks below the normal release with the same MAJOR.MINOR.PATCH, so 1.0.0-alpha < 1.0.0-beta < 1.0.0-rc.1 < 1.0.0.
Why doesn't ^1.2.0 match 1.5.0-beta.1?
npm skips pre-releases unless a comparator in the same part of the range also has a pre-release on the same MAJOR.MINOR.PATCH. This stops users from getting unstable builds by accident. Tick 'Include pre-releases' to match them anyway, like the --include-prerelease flag.
What does the -0 in <2.0.0-0 mean?
It is the lowest possible pre-release of 2.0.0. Writing the upper bound as <2.0.0-0 excludes every 2.0.0 pre-release as well as 2.0.0 itself, which is how npm expands ^1.2.3 internally.
Does build metadata affect version order?
No. Anything after a plus sign, such as +build.42, is ignored when determining precedence, so 1.0.0+a and 1.0.0+b are equal in rank.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.