Compare two SemVer versions

Compare two semantic versions using SemVer 2.0 precedence.

freeworks offlinenothing uploaded
ToolSemVer Comparator
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

Major, minor, and patch numbers are compared numerically; prerelease identifiers sort before the release and compare numeric identifiers numerically but other identifiers lexically. Build metadata after a plus sign is ignored for precedence.

  • SemVer 2.0.0 defines repeatable ordering for release automation.
  • Prerelease and build components remain visible even when they do not increase precedence.

Worked example

A minor version bump
1.10.0 is newer than 1.2.3 because minor version comparison is numeric, not lexical
Input
											Version a: 1.2.3
Version b: 1.10.0
										
Output
												Newer: 1.10.0
Comparison: versionB is newer
Reason: Minor version 10 is greater than 2.
Major diff: no
Minor diff: yes
Patch diff: no
											

When to use this

Package managers, CI release tags, and changelog ordering compare semantic versions.

Edge cases

  • 2.10.0 is newer than 2.9.0 because components are numeric.
  • 1.0.0+linux and 1.0.0+windows have equal precedence.
  • 1.0.0-rc.1 sorts before 1.0.0.

References