Semantic Versioning Cheat Sheet
SemVer rules, version bumping, pre-release and build metadata, ranges, and comparison logic.
Reference
semver
versioning
release
Semantic Versioning encodes compatibility in a version number: MAJOR.MINOR.PATCH. Bumping the right segment signals to consumers whether an upgrade is safe.
The three segments
code
MAJOR.MINOR.PATCH
1 . 2 . 3
Table
| Segment | Increment when |
|---|---|
| MAJOR | Breaking (incompatible) API changes. |
| MINOR | New backward-compatible features. |
| PATCH | Backward-compatible bug fixes. |
Pre-release and build metadata
code
1.2.3-alpha.1
1.2.3-beta.2
1.2.3-rc.1
1.2.3+build.20260816
Table
| Part | Meaning |
|---|---|
-alpha.1 | Pre-release identifier (lower precedence). |
+build.20260816 | Build metadata (ignored in precedence). |
Precedence rules
1.2.3-alpha < 1.2.3(pre-release < release)- Numeric identifiers compare numerically; alphanumeric compare lexically.
1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0
Version bumping
Table
| Change | Bump | Example |
|---|---|---|
| Bug fix | PATCH | 1.2.3 → 1.2.4 |
| New feature | MINOR | 1.2.3 → 1.3.0 |
| Breaking change | MAJOR | 1.2.3 → 2.0.0 |
Range syntax (npm)
Table
| Range | Meaning |
|---|---|
^1.2.3 | Compatible with 1.x (>=1.2.3 <2.0.0). |
~1.2.3 | Patch-level (>=1.2.3 <1.3.0). |
1.2.x | Any patch of 1.2. |
* | Any version. |
>=1.0.0 <2.0.0 | Explicit range. |