Semver Version Increment — Calculate the Next Version

Calculate the next major, minor, or patch version from a given semver string. Understand increment rules, pre-release bumping, and version reset behavior.

Practical Scenarios

Detailed Explanation

Calculating the Next Semver Version

Version incrementing (or "bumping") is the process of determining the next version number based on the type of changes you have made.

Basic Increment Rules

Starting from 1.4.7:

Bump Type Result Rule
patch 1.4.8 Increment PATCH by 1
minor 1.5.0 Increment MINOR by 1, reset PATCH to 0
major 2.0.0 Increment MAJOR by 1, reset MINOR and PATCH to 0

Reset Behavior

Higher-order bumps always reset lower components:

1.4.7  --patch-->  1.4.8
1.4.7  --minor-->  1.5.0   (patch resets)
1.4.7  --major-->  2.0.0   (minor and patch reset)

Pre-release Increments

Incrementing pre-release versions adds complexity:

Starting Version Bump Type Result
1.2.3-alpha.1 prepatch 1.2.4-0
1.2.3-alpha.1 preminor 1.3.0-0
1.2.3-alpha.1 premajor 2.0.0-0
1.2.3-alpha.1 prerelease 1.2.3-alpha.2
1.2.3 prerelease 1.2.4-0

The prerelease bump is special:

  • If the version already has a pre-release tag, it increments the last numeric identifier
  • If the version is a release, it bumps PATCH and appends -0

Using the Increment Tab

Enter any version in the Increment tab to see all six possible next versions at once:

  • Next major, minor, patch
  • Next premajor, preminor, prepatch

Automation with npm version

The npm version command automates incrementing:

npm version patch    # 1.4.7 → 1.4.8
npm version minor    # 1.4.7 → 1.5.0
npm version major    # 1.4.7 → 2.0.0

This command:

  1. Updates package.json version
  2. Creates a git commit
  3. Tags the commit with the new version

Choosing the Right Bump

Change Type Bump Example
Fixed a bug patch Fix null pointer in parser
Added a feature minor New export format option
Changed API signature major Removed deprecated method
Security fix (no API change) patch Patched XSS vulnerability
Dropped Node.js version support major Requires Node >= 20

Use Case

Automating release workflows in CI/CD pipelines, implementing version bump scripts, or manually calculating the next version number before publishing a package update.

Try It — Semver Calculator

Open full tool