Skip to content
OddsockLocal
Local
Source text
Operationparse
ReadyRuns in this browser. Nothing is uploaded.

How to use

  1. Enter a version such as 1.2.3 or 1.2.3-alpha.
  2. Choose parse, major, minor, patch, prerelease, compare or satisfies.
  3. For compare, fill in the other version. For satisfies, fill in an npm range.
  4. Read the bumped version, the -1/0/1 result, or true/false.

What is SemVer calculator?

SemVer calculator takes one version and an operation. Parse prints the parts. major, minor, patch and prerelease bump the version with the usual reset rules: a minor bump of 1.2.3 is 1.3.0, not 1.3.3. Compare needs a second version and returns -1, 0 or 1. Satisfies needs an npm range and returns true or false.

Read more

1.2.3 satisfies the range ^1.0 || 2.x, so the result is true. 1.2.3-alpha compared with 1.2.3 is -1, because a prerelease is older than the release it hangs off. That single minus sign is the rule people get backwards when they expect 1.2.3-alpha to be “newer than 1.2.2 and therefore fine.”

An invalid version fails before any bump. The range field is checked only for satisfies; a compare against a range string is not attempted. The parser page is the same breakdown as the parse operation, without the bump controls.

Use cases

  • A release script should bump minor and you want to see 1.2.3 become 1.3.0 before the script runs.
  • A dependency range ^1.0 || 2.x is in package.json and you want to know if 1.2.3 is inside it.
  • Someone tagged 1.2.3-alpha and thinks it is greater than 1.2.3. Compare shows -1.
  • You need the prerelease identifiers of 2.1.0-alpha.2+b7 without writing a one-off script. Use parse, or the parser page.

A minor bump, and a range check

Version 1.2.3, operation minor. Separately, operation satisfies against ^1.0 || 2.x.

Minor bump: 1.3.0. Satisfies ^1.0 || 2.x: true.

Why use Oddsock

The prerelease comparison is the result worth checking by hand. 1.2.3-alpha is less than 1.2.3, and the page says -1.

Related tools

Using this tool

In semantic versioning a prerelease ranks below the release with the same numbers. Compare returns -1. It does not mean the alpha is older than 1.2.2; it means it is not yet 1.2.3.