Learning navigation

Code with Animation

Semantic Versioning (SemVer)

The strict, three-part numbering system that tells developers exactly how risky an update is.

Package Managers3 min readConcept 5 of 24

What is SemVer?

Semantic Versioning is a convention for communicating changes to a declared public API. npm uses SemVer-compatible versions and ranges for package resolution.

Instead of arbitrary numbers like v1.2 or v2026, SemVer forces a rigid three-part format: MAJOR.MINOR.PATCH (for example, 1.4.2).

The version components communicate the maintainer's compatibility intent. They do not automatically prove that an upgrade will work in your application; review and tests still matter.

Why does it matter?

Before SemVer, updating a dependency was a gamble. A jump from 1.1 to 1.2 might include tiny bug fixes, or it might completely rewrite the API and crash your app.

SemVer creates a binding contract between the package author and the user. By following the rules, tools like npm can automatically pull down safe bug fixes while preventing breaking updates from destroying your production builds.

How it works

For a package following SemVer with an established public API, MAJOR.MINOR.PATCH communicates these changes:

1. MAJOR version when you make incompatible API changes (breaks existing code).

2. MINOR version when you add functionality in a backward-compatible manner.

3. PATCH version when you make backward-compatible bug fixes.

You can also append pre-release tags (like -beta.1) or build metadata (like +exp.sha.5114f85) to the end. A pre-release tag tells npm the version is unstable, giving it a lower precedence than the standard release.

SemVer Interactive Lab

Try adjusting the version components in the interactive lab below to see exactly how npm classifies the release.

Bump Version

Evaluated SemVer

1.4.2
Stable Release

"Stable release"

Check yourself

Pick an answer to lock it in, then read why. Getting one wrong is part of how it sticks.

  1. 1A library at 2.4.1 removes a documented public API. Under SemVer, which release number fits?
  2. 2Which change normally calls for a minor increment from 1.3.2?
  3. 3How does 1.0.0-beta.1 compare with 1.0.0 under SemVer precedence?

Remember this

  • MAJOR breaks the API, MINOR adds features, PATCH fixes bugs.
  • Major version 0 (e.g., 0.x.x) means the API is unstable and can break at any time.
  • Pre-release tags like -alpha.1 indicate the version is unstable and has lower precedence.

Done with this concept?

Mark it complete to track your progress. No login needed.