TR

Home / Guides / What Is Semver? MAJOR.MINOR.PATCH Version Numbers and ^ ~ Ranges

What Is Semver? MAJOR.MINOR.PATCH Version Numbers and ^ ~ Ranges

Updated: November 6, 2026 · AracMerkezi

▶ Open Semver Version Comparator

If a software package’s version consists of three numbers such as 2.4.1, it is most likely using semantic versioning (semver). This method lets you judge from the version number how risky an update is. npm, Cargo, Composer and many other package managers are built on this scheme. This guide explains the bump rules, how versions are ordered, and which version the ^ and ~ ranges select, using tested examples.

What the three numbers mean

The version number has the form MAJOR.MINOR.PATCH:

When one number increases, the numbers to its right reset to zero: after 1.4.7, a bug fix is 1.4.8, a new-feature release is 1.5.0, and a major release is 2.0.0 (we confirmed this with the inc function of npm’s semver package).

Which change bumps which number?

ChangeNumber that increasesAfter 1.4.7
A bug was fixed, the API is the samePATCH1.4.8
A new function was added, old ones still workMINOR1.5.0
A function’s name or return type changedMAJOR2.0.0

One question is enough to decide: “If someone using the old version updates, will they have to change their code?” If yes, MAJOR increases.

How are versions compared?

Comparison is done left to right, numerically. The most common mistake is sorting versions like text:

Try it: in JavaScript, ['1.9.0','1.10.0','1.2.3'].sort() gives 1.10.0, 1.2.3, 1.9.0 in text order; the correct order is 1.2.3, 1.9.0, 1.10.0. When sorting versions, always use a library that compares numerically.

Pre-release tags

Versions that are not stable are tagged with a hyphen: 1.0.0-alpha, 1.0.0-beta.2, 1.0.0-rc.1. A pre-release is always considered lower than the stable version of the same number. Ordering example:

  1. 1.0.0-alpha
  2. 1.0.0-alpha.1
  3. 1.0.0-beta
  4. 1.0.0-rc.1
  5. 1.0.0

Pre-release parts are separated by dots; numbers are compared numerically and alphabetic parts alphabetically, so 1.0.0-beta.2 comes before 1.0.0-beta.11. Build metadata added with a plus sign (1.0.0+build.5) is ignored in ordering: 1.0.0+build.5 and 1.0.0+build.9 have equal precedence.

The ^ and ~ range operators

When writing version ranges in files such as package.json, two shortcuts are used a lot (npm rules):

NotationMeaningExample range
^1.2.3Keep the major version fixed1.2.3 and above, below 2.0.0
~1.2.3Keep the minor version fixed1.2.3 and above, below 1.3.0
^0.2.3In 0.x versions, keep the minor fixed0.2.3 and above, below 0.3.0
^0.0.3Only that exact version0.0.3 and above, below 0.0.4

Because versions starting with zero are considered “unstable”, the ^ operator works more narrowly in these cases. Wildcard forms such as 1.x and 1.2.x, and explicit ranges such as >=1.2.0 <2.0.0, can also be used; >=1.2.0 <2.0.0 describes the same set as ^1.2.0.

Example 1: Which version gets installed?

Suppose these versions are published in the registry: 1.2.2, 1.2.3, 1.4.0, 1.9.5, 2.0.0, 2.1.0. If you wrote ^1.2.3, the highest version that stays on major 1 is chosen: 1.9.5. 1.2.2 is too low, and 2.0.0 and 2.1.0 are a new major version; both are left out. With the same list, ~1.2.3 could be at most 1.2.x; since the list has 1.2.3, the result would be 1.2.3. The line "dependencies": {"example-package": "^1.2.3"} in package.json makes this choice at install time; the lock file records the chosen version (1.9.5 here) and later installs get the same version, so even if a new 1.9.6 is published, nothing changes until you run the update command.

Example 2: Patch updates with ~

Versions: 1.2.2, 1.2.3, 1.2.8, 1.3.0, 2.0.0. The ~1.2.3 range covers 1.2.3 up to 1.3.0 (excluding 1.3.0): 1.2.8 is installed. ^1.2.3 would also accept 1.3.0. For packages where you want to be more cautious, ~ is preferred.

Example 3: The 0.x trap

If you wrote ^0.2.3, 0.2.9 matches but 0.3.0 does not; ^0.0.3 leaves out even 0.0.4. So for 0.x packages, ^ is narrower than you might expect. Pre-releases have a separate rule too: the range ^1.2.3 does not select 1.3.0-beta.1, because pre-releases are accepted only for the same version triple when the range itself is written with a pre-release (for example, ^1.2.3-beta.2 accepts 1.2.3-beta.4).

Practical tips

Limits

Semver is a promise, not a guarantee. A package maintainer can accidentally change behavior in a patch. That is why you need to run your tests after automatic updates. Also, not all projects use semver; some use calendar-based versioning (such as 2026.10). Range notation (^, ~) can differ slightly from tool to tool; the examples in this article were verified with version 7.x of npm’s semver package.

Common mistakes

A short checklist

Before a release, check: Was the change note written? Is there a backward-incompatible change? Does the version number match the type of change? Are the tag and the package version the same? These four questions prevent most version confusion.

Glossary

Tools

The Semver Version Comparator shows which of two versions is newer. While editing your package.json, you can validate the structure with the JSON Formatter. For scheduled tasks, also take a look at the guide How to Write a Cron Expression.

Frequently asked questions

What do MAJOR, MINOR and PATCH mean?

MAJOR marks backward-incompatible changes, MINOR marks backward-compatible new features, and PATCH marks backward-compatible bug fixes.

Which is newer, 1.2.3 or 1.10.0?

1.10.0 is newer; versions are compared numerically from left to right, and 10 is greater than 2.

Which versions does ^1.2.3 cover?

Under npm rules it covers 1.2.3 and above, up to but not including 2.0.0; ~1.2.3 covers versions up to 1.3.0.

Tools mentioned in this guide

More guides

This article is for general information only and is not legal, financial or medical advice. We are not an official institution.