DevTools Logo

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
SegmentIncrement when
MAJORBreaking (incompatible) API changes.
MINORNew backward-compatible features.
PATCHBackward-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
PartMeaning
-alpha.1Pre-release identifier (lower precedence).
+build.20260816Build metadata (ignored in precedence).

Precedence rules

  1. 1.2.3-alpha < 1.2.3 (pre-release < release)
  2. Numeric identifiers compare numerically; alphanumeric compare lexically.
  3. 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0

Version bumping

Table
ChangeBumpExample
Bug fixPATCH1.2.3 → 1.2.4
New featureMINOR1.2.3 → 1.3.0
Breaking changeMAJOR1.2.3 → 2.0.0

Range syntax (npm)

Table
RangeMeaning
^1.2.3Compatible with 1.x (>=1.2.3 <2.0.0).
~1.2.3Patch-level (>=1.2.3 <1.3.0).
1.2.xAny patch of 1.2.
*Any version.
>=1.0.0 <2.0.0Explicit range.

References

Related tools