A semantic version is MAJOR.MINOR.PATCH: bump MAJOR for incompatible changes, MINOR for backward-compatible features and PATCH for backward-compatible fixes. Package managers describe acceptable versions with ranges. Test any range against any version with the Semver Range Checker; the idea behind the numbers is in Semantic Versioning (SemVer).
Range operators
| Range | Expands to | Matches (examples) | Does not match |
|---|---|---|---|
^1.2.3 |
>=1.2.3 <2.0.0 |
1.2.3, 1.9.9 |
2.0.0, 1.2.2 |
~1.2.3 |
>=1.2.3 <1.3.0 |
1.2.3, 1.2.9 |
1.3.0, 1.2.2 |
^0.2.3 |
>=0.2.3 <0.3.0 |
0.2.3, 0.2.9 |
0.3.0, 0.2.2 |
^0.0.3 |
>=0.0.3 <0.0.4 |
0.0.3 |
0.0.4, 0.0.2 |
^1.2 |
>=1.2.0 <2.0.0 |
1.2.0, 1.9.9 |
2.0.0, 1.1.9 |
~1 |
>=1.0.0 <2.0.0 |
1.0.0, 1.9.9 |
2.0.0, 0.9.9 |
1.x |
>=1.0.0 <2.0.0 |
1.0.0, 1.9.9 |
2.0.0, 0.9.9 |
1.2.x |
>=1.2.0 <1.3.0 |
1.2.0, 1.2.9 |
1.3.0, 1.1.9 |
>=1.2.7 <1.3.0 |
>=1.2.7 <1.3.0 |
1.2.7, 1.2.99 |
1.3.0, 1.2.6 |
1.2.3 - 2.3.4 |
>=1.2.3 <=2.3.4 |
1.2.3, 2.3.4 |
2.3.5, 1.2.2 |
<2.0.0 || >=3.0.0 |
<2.0.0 || >=3.0.0 |
1.9.9, 3.0.0 |
2.5.0, 2.0.0 |
^1.2.3-beta.2 |
>=1.2.3-beta.2 <2.0.0 |
1.2.3-beta.2, 1.2.3 |
1.2.3-beta.1, 2.0.0 |
Prerelease versions
Prerelease versions sort below the release they precede, and their identifiers compare field by field (numbers numerically, words alphabetically, a longer set of fields after a shorter one):
1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0
A range only matches a prerelease when the range itself names a prerelease on the same MAJOR.MINOR.PATCH. So >1.2.3 does not match 1.3.0-beta, while ^1.2.3-beta.2 matches 1.2.3-beta.4. Most tools offer an option to include prereleases explicitly.
Quick rules
^allows changes that do not modify the left-most non-zero number. Below 1.0.0, that makes^0.2.3as strict as~0.2.3.~allows patch-level changes when a minor is given (~1.2.3), and minor-level changes when only a major is given (~1).- A space between comparators means AND;
||means OR. - Build metadata after
+(1.0.0+20261028) is ignored when comparing versions. - Version bumps:
1.2.3becomes1.2.4(patch),1.3.0(minor) or2.0.0(major);1.2.3-beta.1bumps to1.2.3-beta.2. - Python's PEP 440 uses different operators (
~=,==1.*) and spellings (1.0rc1); Cargo follows npm's caret rules by default.