SemVer Cheatsheet

Table of Contents

Semver, short for “semantic versioning” is a versioning system that encodes the impact of changes between releases on the public interface directly into the version string.

Semver

Given a version number MAJOR.MINOR.PATCH:

Change inImpact
MAJORincompatible API changes
MINORadd functionality (backwards-compatible)
PATCHbug fixes (backwards-compatible)

Simple ranges

  1.2.3
 =1.2.3
 >1.2.3
 <1.2.3
>=1.2.3

Note that suffixed versions (1.2.3-rc1) are not matched.

Ranges

RangeDescriptionNotes
~1.2.3is >=1.2.3 <1.3.0Only accept patch updates
^1.2.3is >=1.2.3 <2.0.0Accept minor and patch updates
^0.2.3is >=0.2.3 <0.3.0(0.x.x is special)
^0.0.1is =0.0.1(0.0.x is special)
^1.2is >=1.2.0 <2.0.0(like ^1.2.0)
~1.2is >=1.2.0 <1.3.0(like ~1.2.0)
^1is >=1.0.0 <2.0.0
~1same
1.xsame
1.*same
1same
*any version
xsame

Hyphenated ranges

RangeDescription
1.2.3 - 2.3.0is >=1.2.3 <=2.3.4

Partial right

RangeDescription
1.2.3 - 2.3is >=1.2.3 <2.4.0
1.2.3 - 2is >=1.2.3 <3.0.0

Partial left

RangeDescription
1.2 - 2.3.0is 1.2.0 - 2.3.0

When the right is partial (eg, 2.3), missing pieces are assumed to be x (eg, 2.3.x).

When the left is partial (eg, 1.2), missing pieces are assumed to be 0 (eg, 1.2.0).

Combining ranges

RangeDescription
>=0.14 <16And (space-separated)
0.14.x || 15.x.xOr (pipe-separated)

Pre-releases

1.2.3-prerelease+build

Explanation

VersionExplanation
^means “compatible with”
~means “reasonably close to”
0.x.xis for “initial development”
1.x.xmeans public API is defined

References