Semantic Versioning Explained: When to Bump Major, Minor, or Patch

Semantic Versioning Explained: When to Bump Major, Minor, or Patch

Semantic versioning explained in plain terms: it is a simple contract between a library author and everyone who installs it. A version number like 2.4.1 is not a random label. It tells you whether an update is safe to install, whether it adds something new, and whether it might break your code.

Most developers have felt the pain of a bad version bump: you run an update, nothing in your code changed, and the build fails anyway. The cause is usually simple. Someone bumped the wrong number.

Semantic Versioning Explained: The MAJOR.MINOR.PATCH Format

A semantic version has three numbers separated by dots: MAJOR.MINOR.PATCH. Each number has one job.

  • MAJOR goes up when you make a change that breaks existing code. Version 1.4.2 becomes 2.0.0.
  • MINOR goes up when you add a feature that stays compatible with the old code. Version 1.4.2 becomes 1.5.0.
  • PATCH goes up when you fix a bug without changing how anything works. Version 1.4.2 becomes 1.4.3.

When a number goes up, the numbers after it reset to zero: a major bump turns 1.4.2 into 2.0.0, not 2.4.2. That reset tells readers exactly how far the change reached.

The first stable release is 1.0.0. Before that, versions starting with 0, like 0.3.0, mean the public API is still settling: a minor bump can carry breaking changes, because the project has not promised stability yet. Once you ship 1.0.0, the contract starts.

When to Bump Major: Breaking Changes

Bump major when existing code that worked before will stop working, or behave differently in a way the caller did not ask for. If a user has to change their code to keep using your library, that is a major bump.

Concrete cases that count as breaking:

  • Removing or renaming a function. A library drops getUser(id) and replaces it with getUser({ id }). Every caller must edit their code.
  • Changing a function signature. A parameter that was optional becomes required, or arguments change order.
  • Changing what a function returns. An API that returned an array now returns an object with a data field. Code that looped over the result breaks on the spot.
  • Dropping a supported runtime. A library stops supporting Node.js 16. Users on that runtime can no longer upgrade at all.
  • Removing an endpoint or a field. A REST API removes the nickname field from its user response. Clients that read it get undefined.

Real projects follow this pattern in public. React went from 18 to 19 when it changed how refs work and removed legacy APIs. Express moved from 4 to 5 after changing routing behavior and dropping old Node versions. Python 2 to Python 3 is the famous extreme case: the print statement became a function, and years of code needed edits.

If you ship a breaking change as a minor bump, package managers install it automatically for users with a caret range like ^1.4.0, and their builds break without warning. When a bad release slips out, roll it back first and sort out the version number second. The steps for rolling back a broken deployment with Docker tags apply here too.

When to Bump Minor: New Features, Same Contract

Bump minor when you add something new and everything that worked before still works. Old code keeps running untouched, and new code can use the new feature.

Concrete cases that count as minor:

  • Adding a new function or method. A date library adds formatRelative() next to the existing format(). Nothing old changes.
  • Adding an optional parameter. A function gains a new third argument with a default value. Callers who pass two arguments see no difference.
  • Adding a new endpoint. An API gains GET /users/:id/orders while every old endpoint keeps its shape.
  • Adding a new config option. A tool adds a retry setting that defaults to off.

Take a real example. A logging library at version 1.4.0 adds JSON output as a new option. Users who never touch the option get the same plain-text logs as before. The release ships as 1.5.0, and anyone on 1.4.x can upgrade without a migration guide.

Minor releases are also where teams add deprecations. You can mark an old function as deprecated in a minor release, but you must keep it working. The removal itself waits for the next major. That two-step rhythm keeps upgrades boring.

When to Bump Patch: Fixes That Change Nothing Else

Bump patch when you fix a bug without changing the public behavior your users rely on. The code was wrong, now it is right, and nobody needs to change how they call it.

Concrete cases that count as patch:

  • Fixing an off-by-one error. A pagination helper skipped the last item on page two. The fix returns the item it should have returned all along.
  • Fixing a crash on an edge case. A parser threw an error on empty input. It now returns an empty result.
  • Fixing a typo in an error message. No code depends on the exact wording, so nothing breaks.
  • Fixing a security flaw without changing the API. A dependency update or an input check closes a hole. The interface stays identical.

A common mistake is bumping minor for a bug fix because the fix felt big. Size does not decide the number. What decides it is whether users must change their code. A one-line fix and a thousand-line fix can both be patches if the public behavior stays the same.

The reverse mistake is just as common: shipping a behavior change as a patch because it looked small. If your “fix” changes the order of items a function returns, that is not a patch.

Pre-Release Versions and Build Metadata

Not every release is meant for everyone. A hyphen marks a pre-release: 2.0.0-alpha.1, 2.0.0-beta.2, 2.0.0-rc.1. These come before the matching stable release, so 2.0.0-rc.1 is older than 2.0.0. Package managers treat pre-releases as opt-in, which is what you want when early users test a breaking change before it goes wide.

A plus sign marks build metadata: 1.4.1+build.20261121. Package managers ignore build metadata when comparing versions, so 1.4.1+build.20261121 and 1.4.1+build.20261122 count as the same version. Use it to record which commit produced the package, never to signal a difference that matters.

A practical pattern: publish 2.0.0-rc.1 two weeks before the real 2.0.0 and let early adopters find the migration problems you missed in staging. That staging step matters, and setting up a staging environment on a separate VPS gives a release candidate a place to prove itself before production.

Common Mistakes Teams Make

Shipping a breaking change as a minor bump. A team renames a config key in version 1.6.0, calls it a minor, and every user with a caret range upgrades automatically into a broken deploy. If the change breaks callers, it is major. No exceptions.

Bumping major for a bug fix. Users see 2.0.0, assume a painful migration, and stay on 1.x for months. Meanwhile the fix they need sits in the major release they are avoiding. A major bump that carries no breaking change is a false alarm.

Treating 0.x versions as stable. Before 1.0.0, anything can change, and the spec says so. Teams that build production systems on a 0.4.2 library and then complain about a breaking 0.5.0 missed the point of the zero.

Forgetting that the version number is a team decision. The person who writes the code is often the worst judge of whether it breaks anyone, because they know the new API by heart. Many teams tie version bumps to commit messages. conventional commits make that mechanical: feat suggests a minor bump, fix suggests a patch, and a BREAKING CHANGE footer forces a major.

A Quick Decision Checklist

When you are unsure which number to bump, check this table before you publish.

What changed Bump Example
Removed or renamed a public function MAJOR 1.4.2 becomes 2.0.0
Changed a return type or response shape MAJOR 1.4.2 becomes 2.0.0
Added a new function or endpoint MINOR 1.4.2 becomes 1.5.0
Added an optional parameter MINOR 1.4.2 becomes 1.5.0
Fixed a bug without changing behavior PATCH 1.4.2 becomes 1.4.3

Once the rule is clear, automate it. Version bumps decided by hand in a release meeting drift over time. Tools that read commit history and propose the next version remove the guesswork, and most teams wire that step into their pipeline. If your pipeline is not there yet, compare the best CI/CD tools for 2026 and pick one that can run a version check on every merge. A major release also deserves a careful rollout: a blue-green or canary deployment strategy lets you ship 2.0.0 to a small slice of traffic first and roll back in seconds if the breaking change breaks more than expected.

Semantic versioning works as a shared language. MAJOR means stop and read the changelog. MINOR means new things, nothing lost. PATCH means safe to install right now. Keep that promise, and your users will upgrade without fear.

Ditulis oleh

Firdaus Safari Putra

Founder, PT FirKaizen Digital Solutions

Firdaus Safari Putra adalah founder PT FirKaizen Digital Solutions. Ia membangun dan mengoperasikan infrastruktur server di balik panduan ini, dan menulis berdasarkan apa yang benar-benar ia jalankan, uji, dan ukur — bukan teori.