A version number is a message to developers: “this update is safe” or “expect breakage”. Semantic versioning turns it into a contract: if a library goes from 2.3.0 to 3.0.0, the API changed incompatibly and your code needs checking; if it goes to 2.3.1, you can update without reading the changelog.
What a version number consists of
| Part | When it changes | Example bump |
|---|---|---|
| MAJOR | incompatible changes: an API is removed or altered | 2.3.1 → 3.0.0 |
| MINOR | new functionality that stays backward compatible | 2.3.1 → 2.4.0 |
| PATCH | bug fixes with no change to the API | 2.3.0 → 2.3.1 |
Version 2.3.1 means MAJOR 2, MINOR 3, PATCH 1: the second generation of the API, the third batch of new features, the first fix. Initial development happens under 0.y.z: the specification allows anything to change at any time, and 1.0.0 is considered the first stable release. The main rules:
- Once a version is released, its contents never change: fixes ship as a new version.
- When MAJOR goes up, MINOR and PATCH reset to zero (
2.3.1→3.0.0); when MINOR goes up, PATCH resets (2.3.1→2.4.0). - Declaring an API deprecated (
deprecation) requires a MINOR bump: before a function is removed in a new MAJOR, at least one MINOR release must ship with a warning. 0.y.zis for initial development: the API is not guaranteed and anything may change.- The
vprefix is common in tags (git tag v1.2.3), but according to the specification the version itself is just numbers separated by dots.
Prerelease and update ranges
1.2.0-rc.1+build.20261107A hyphen adds a prerelease label for a version that is not ready yet: 1.2.0-alpha.1, 1.2.0-beta.2, 1.2.0-rc.1 (release candidate). The + sign introduces build metadata (1.2.0+build.77), which is ignored when comparing versions. A prerelease always sorts below its release: 1.2.0-alpha < 1.2.0-beta < 1.2.0.
In package.json, requirements.txt and other dependency files, a version comes with a constraint: the range of updates you accept. The syntax differs between package managers, but the idea is the same; in npm notation:
^1.2.3— 1.2.3 or newer, but within MAJOR version 1: no breaking changes;~1.2.3— 1.2.3 or newer, but within the same MINOR: no new features;>=1.2 <2.0— a range built from comparison operators.
A “^” or “~” range together with a lock file that pins exact versions gives you updates without surprises: the range for new installs, the lock file for reproducibility.
Where it is used
SemVer is the common convention in open ecosystems: npm, Cargo, Go modules. But nobody is obliged to follow it: some projects ship breaking changes under a MINOR bump. So the number is a good guide, but you should still check key dependencies against the changelog.
Sources
the term is written from these pagesVerified 9 Nov