Skip to main content
QUIETLYTIC
Developer

SemVer Comparator

Compare two versions using SemVer 2.0.0 precedence, not string sort.

Local · nothing leaves this browser Waiting for two versions
Esc Clear
Esc Clear
Comparison

Enter two versions above.

How it works

SemVer 2.0.0 precedence is not string or numeric-tuple comparison — 1.10.0 outranks 1.2.0 even though "1.10.0" < "1.2.0" as a string, and a prerelease always sorts below its own release (1.0.0-alpha < 1.0.0). This compares using the spec's actual rules, not an approximation.

Prerelease identifiers compare field by field

1.0.0-alpha.1 and 1.0.0-alpha.beta are compared identifier by identifier, split on `.`: a purely-numeric identifier compares numerically, an alphanumeric one compares lexically, and a numeric identifier always sorts lower than an alphanumeric one at the same position. Build metadata (+build.1) is not compared at all — it carries no precedence under the spec.

Example

1.10.0 vs 1.9.0 reports A greater, a minor-version difference — the exact case a naive string sort gets backwards.

Frequently asked questions

Why does 1.10.0 beat 1.2.0 here but not in a plain string sort?

Because SemVer compares each dot-separated field numerically, not the string as a whole — "1.10.0" < "1.2.0" as text (1 < 2 at that character position) but 10 > 2 as a number, and the number is what the spec actually says to compare.

How are prerelease identifiers like alpha.1 vs alpha.beta compared?

Field by field, split on the dot: a purely numeric field compares numerically, an alphanumeric one compares as a string, and a numeric field always sorts below an alphanumeric one at the same position. Build metadata after a + carries no precedence at all under the spec and is ignored entirely.

Related tools

From the intelligence desk