Semantic versioning

Semantic versioning (SemVer) is a convention that gives every release a number of the form MAJOR.MINOR.PATCH and ties each part to a kind of change. The major number rises for incompatible changes to the public API, the minor number for backward compatible new functionality, and the patch number for backward compatible bug fixes.

The longer version

The rules come from the Semantic Versioning specification, published at semver.org and originally authored by Tom Preston-Werner, the inventor of Gravatar and cofounder of GitHub, as a way out of what it calls dependency hell, where version rules that are too tight or too loose stop a project from upgrading safely. The current edition is 2.0.0, and this page follows it. The specification starts from a condition: software using it must declare a public API, because each of the three numbers is defined by what a change does to that API. A version takes the form X.Y.Z, where each part is a non-negative integer with no leading zeroes and each increases numerically, so 1.9.0 is followed by 1.10.0. Once a version has been released its contents must not be modified, and any modification has to go out as a new version.

Each increment is a promise to whoever depends on the software. The patch number must rise when only backward compatible bug fixes are introduced. The minor number must rise when backward compatible functionality is added to the public API, or when any part of that API is marked as deprecated, and the patch number then returns to zero. The major number must rise when any backward incompatible change reaches the public API, and both lower numbers return to zero. Two special cases frame the scheme. Major version zero is for initial development, where the specification says "Anything MAY change at any time", and version 1.0.0 is the one that defines the public API.

Two optional labels extend the format. A pre-release is written with a hyphen and dot-separated identifiers, as in 1.0.0-alpha.1, and ranks below the normal version it leads up to, which is how a release candidate such as 1.0.0-rc.1 gets its number. Build metadata follows a plus sign, as in 1.0.0+20130313144700, and must be ignored when versions are ordered, so two versions that differ only in their build metadata have the same precedence.

For a tester the number is a first estimate of scope. A patch release claims to hold fixes only, so the fixed defects are retested and a regression pass covers their surroundings. A minor release adds behaviour to test and promises that existing integrations keep working, which is itself a claim to check. A major release announces that something will break, and the changelog or the release notes should say what. The number is a statement by the author and can be wrong: the specification's own FAQ deals with a breaking change that slips into a minor release, and its remedy is a corrected new version, never a modified old one. A bug report that records the exact version, including any pre-release label, tells the developer which build to open.

Common questions

What is semantic versioning?

Semantic versioning is a numbering convention in which a version has three parts, MAJOR.MINOR.PATCH, and each part changes for a defined reason. An incompatible API change raises the major number, a backward compatible addition raises the minor number, and a backward compatible bug fix raises the patch number.

What do the three numbers in a semantic version mean?

Reading 4.2.7 from the left, 4 is the major version, 2 the minor version and 7 the patch version. Under Semantic Versioning 2.0.0, a move to 4.2.8 signals bug fixes only, 4.3.0 signals new backward compatible functionality or a deprecation, and 5.0.0 signals a change that existing users of the public API may have to adapt to.

What does a pre-release label such as -beta or -rc mean?

A label after a hyphen marks a pre-release version. Semantic Versioning 2.0.0 gives it lower precedence than the associated normal version, so 2.0.0-rc.1 comes before 2.0.0, and describes it as unstable and as possibly not meeting the compatibility requirements of that version. Text after a plus sign is build metadata and plays no part in ordering.

What does a version number tell a tester?

A semantic version tells a tester how large a change the author claims to have made. A patch increment points to retesting the fixed defects and a regression pass around them, a minor increment adds new behaviour to cover, and a major increment warns that existing behaviour was deliberately broken somewhere. The claim still has to be checked against the changelog and the build.

When should a project release version 1.0.0?

The specification's FAQ offers three signs: software already used in production should probably be 1.0.0, software with a stable API that users have come to depend on should be 1.0.0, and a team worrying a lot about backward compatibility has probably reached it. Before that point, 0.y.z versions carry no promise of stability.

What are some examples of semantic versioning?

Starting from 2.6.9, a bug fix gives 2.6.10, a new backward compatible feature gives 2.7.0, and a breaking API change gives 3.0.0. Pre-releases look like 3.0.0-alpha.1 or 3.0.0-rc.2, and build metadata like 3.0.0+build.42. Wikipedia's version of the point: software relying on 2.1.5 of an API works with 2.2.3, and not necessarily with 3.2.4.

What do the caret and tilde mean in npm versions?

They are ranges built on semantic versioning. In a package.json, ~1.0.4 accepts patch releases of 1.0 from 1.0.4 upwards, and ^1.0.4 accepts minor and patch releases of 1, so 1.2.0 qualifies and 2.0.0 does not. An asterisk or x accepts any version, including new majors. The ranges only work as well as the packages' authors follow the rules.

Is v1.2.3 a semantic version?

The specification's FAQ says it is not: v1.2.3 is a tag name, and the semantic version is 1.2.3. Prefixing a Git tag with v, as in git tag v1.2.3, is a common convention and harmless, as long as tools that compare versions strip the prefix before they do.

What is the difference between calendar versioning and semantic versioning?

Semantic versioning numbers a release by what it does to the API. Calendar versioning, or CalVer, numbers it by when it came out: Ubuntu's YY.0M scheme makes 26.04 the April 2026 release, and JetBrains uses YYYY.MINOR. CalVer tells you how old a version is, and SemVer tells you whether upgrading to it is safe.

What if a breaking change ships by mistake?

The specification's answer is a new version, never an edit to the old one. A release that broke compatibility should be followed by a release that restores it, with the faulty version documented. Where restoring the intended behaviour would itself disrupt a large audience, the specification says a major version may be the better choice, even for what is strictly a patch.

Bug reports that arrive ready to triage.

Collect replay, console, network and browser context with the Free plan.

<script src="…/widget.js" data-key="pb_pub_…">