ToolNimba Browse

🔢 Semantic Version Comparator

By ToolNimba Web Dev Team · Updated 2026-06-19

Comparison
-
-
Version A parsed
Major: -
Minor: -
Patch: -
Prerelease: -
Build: -
Version B parsed
Major: -
Minor: -
Patch: -
Prerelease: -
Build: -

Enter two versions to compare them by semantic versioning precedence.

This semver comparator tells you which of two version numbers is newer under the rules of Semantic Versioning. Paste a version into each box, for example 1.4.2 and 1.4.2-rc.1, and it validates the format, splits each into major, minor, patch and prerelease, then reports which is greater or whether they rank equally. It is the quick way to settle whether 1.0.10 beats 1.0.9 or whether a release candidate sorts below the final release.

What is the Semver Comparator?

Semantic Versioning (semver) is a convention for numbering software releases so that the number itself carries meaning. A version has the shape MAJOR.MINOR.PATCH, such as 2.5.1. You bump the major number for breaking changes, the minor number for new but backward-compatible features, and the patch number for backward-compatible bug fixes. Optionally a hyphen introduces a prerelease label (1.0.0-rc.1) and a plus sign introduces build metadata (1.0.0+20130313144700). This shared grammar is what lets package managers like npm, Cargo and Composer reason about which versions satisfy a range.

Comparing two versions follows a strict precedence order. First the major, minor and patch numbers are compared numerically, left to right, and these are integers, not decimals, so 1.0.10 is greater than 1.0.9 (ten is more than nine) even though as a decimal 0.10 looks smaller than 0.9. Only if all three core numbers are identical does the prerelease section decide the order. A version that carries a prerelease label always ranks lower than the same version without one, because a prerelease comes before the final release it is leading up to: 1.0.0-rc.1 is less than 1.0.0.

When both versions are prereleases of the same core version, their labels are compared identifier by identifier, split on the dots. Numeric identifiers are compared as numbers and always rank below non-numeric ones, alphanumeric identifiers are compared in ASCII sort order, and if every shared identifier matches, the label with more identifiers wins. This gives the canonical chain 1.0.0-alpha is less than 1.0.0-alpha.1, which is less than 1.0.0-beta, which is less than 1.0.0-rc.1, which is less than 1.0.0. Build metadata (the part after the plus sign) is ignored entirely when comparing, so 1.0.0+build.1 and 1.0.0+build.99 have equal precedence.

When to use it

  • Settling whether a deployed version is newer than the one in a changelog or lockfile before you roll back or upgrade.
  • Checking that a release candidate or beta tag sorts below the final release it is meant to precede.
  • Confirming that 1.0.10 is correctly treated as newer than 1.0.9, a frequent source of sorting bugs in naive string compares.
  • Teaching or sanity-checking how npm, Cargo or Composer will order two versions when resolving a dependency range.

How to use the Semver Comparator

  1. Type the first version into the Version A box, for example 1.2.3.
  2. Type the second version into the Version B box, for example 1.2.3-rc.1.
  3. Read the verdict: it tells you which version is greater, or that the two are equal in precedence.
  4. Check the parsed parts below to see how each version split into major, minor, patch, prerelease and build.

Formula & method

Precedence compares MAJOR, then MINOR, then PATCH as integers. If all are equal, a version with a prerelease ranks lower than one without. Prerelease labels compare identifier by identifier (numeric below alphanumeric, more identifiers wins on ties). Build metadata is ignored.

Worked examples

Compare 1.0.9 with 1.0.10.

  1. Major: 1 = 1, so move on.
  2. Minor: 0 = 0, so move on.
  3. Patch: compare as integers, 9 vs 10.
  4. 10 is greater than 9, so 1.0.10 wins.

Result: 1.0.10 is greater than 1.0.9

Compare 1.0.0-rc.1 with 1.0.0.

  1. Major, minor and patch are all equal (1.0.0).
  2. 1.0.0-rc.1 carries a prerelease label; 1.0.0 does not.
  3. A prerelease always ranks lower than the matching final release.

Result: 1.0.0 is greater than 1.0.0-rc.1

Compare 1.0.0-beta.2 with 1.0.0-beta.11.

  1. Core versions are equal and both are prereleases.
  2. Split labels on dots: [beta, 2] vs [beta, 11].
  3. First identifier beta = beta.
  4. Second identifier: both numeric, compare as numbers, 2 vs 11.
  5. 11 is greater than 2.

Result: 1.0.0-beta.11 is greater than 1.0.0-beta.2

Canonical semver precedence chain (lowest to highest)

OrderVersionWhy it sorts here
1 (lowest)1.0.0-alphaPrerelease, single alphanumeric identifier
21.0.0-alpha.1Same as above plus an extra numeric identifier
31.0.0-alpha.betabeta sorts after the numeric 1
41.0.0-betabeta is greater than alpha
51.0.0-beta.2Adds a numeric identifier
61.0.0-beta.1111 is greater than 2 as a number
71.0.0-rc.1rc sorts after beta
8 (highest)1.0.0Final release outranks every prerelease

What each part of a version means

PartExampleWhen it changes
Major2.x.xBackward-incompatible (breaking) changes
Minorx.5.xNew backward-compatible features
Patchx.x.1Backward-compatible bug fixes
Prerelease-rc.1Unstable build leading up to a release
Build metadata+20130313Build info, ignored when comparing

Common mistakes to avoid

  • Comparing versions as plain strings. A string compare puts 1.0.9 above 1.0.10 because the character 9 sorts after 1. Semver compares the patch numbers as integers, so 1.0.10 is correctly the newer version.
  • Treating the version as a decimal number. A version is not 1.10 the decimal. The dots separate independent integers, so minor 10 is ten releases after minor 9, not a smaller fraction.
  • Assuming a prerelease outranks the release. A label like 1.0.0-rc.1 looks fuller and may feel later, but a prerelease always ranks below the matching final release 1.0.0. It is the version that comes before, not after.
  • Expecting build metadata to break a tie. The part after a plus sign is build metadata and is ignored for precedence. 1.0.0+build.1 and 1.0.0+build.2 are equal in rank, so do not rely on it to order releases.
  • Writing prerelease numbers with leading zeros. A numeric prerelease identifier may not have a leading zero, so 1.0.0-rc.01 is invalid. Use 1.0.0-rc.1 instead, or treat it as an alphanumeric label.

Glossary

Semantic Versioning (semver)
A versioning scheme of the form MAJOR.MINOR.PATCH where each number signals the kind of change made.
Major
The first number, bumped when a release introduces backward-incompatible (breaking) changes.
Minor
The second number, bumped when new backward-compatible features are added.
Patch
The third number, bumped for backward-compatible bug fixes only.
Prerelease
An optional label after a hyphen (such as -alpha or -rc.1) marking an unstable build that ranks below the final release.
Build metadata
An optional label after a plus sign (such as +20130313). It is recorded but ignored when comparing precedence.
Precedence
The order semver defines for two versions, deciding which one is newer or whether they rank equally.

Frequently asked questions

How do I compare two semantic versions?

Compare the major, then minor, then patch numbers as integers, left to right. If all three match, a version with a prerelease label ranks lower than one without. If both have prereleases, compare their labels identifier by identifier. This tool does all of that and shows the verdict instantly.

Is 1.0.10 greater than 1.0.9?

Yes. The patch parts are compared as whole numbers, and 10 is greater than 9, so 1.0.10 is the newer version. A naive string compare gets this wrong because it sees the character 1 as sorting before 9.

Why is a release candidate lower than the final release?

By the semver rules a prerelease (such as 1.0.0-rc.1) has lower precedence than the matching normal version (1.0.0). A prerelease is a stepping stone toward the release, so it comes first in the ordering, not after.

Does build metadata affect the comparison?

No. Anything after a plus sign, like +build.42, is build metadata and is ignored entirely when ranking versions. So 1.0.0+build.1 and 1.0.0+build.99 have equal precedence in this tool.

How are prerelease labels like beta.2 and beta.11 ordered?

The label is split on dots into identifiers. Numeric identifiers are compared as numbers, so beta.11 is greater than beta.2. Numeric identifiers rank below alphanumeric ones, and when all shared identifiers match, the label with more identifiers wins.

What counts as a valid version here?

A valid version is three non-negative integers separated by dots (no leading zeros), with an optional -prerelease and an optional +build, for example 1.4.2, 2.0.0-rc.1 or 1.0.0+exp.sha. A leading v or = is tolerated; anything else is flagged as invalid.