Semantic Version Comparator

Compare semantic version numbers and see which is newer.

Open tool

Overview

Enter two semantic version strings and the comparator reports which is newer, equal, or older - including correct handling of pre-release identifiers (1.0.0-rc.1 is less than 1.0.0) and build metadata (which is ignored for comparison).

It's for developers writing dependency resolvers, release workflows, or migration scripts that need to gate behaviour on version differences. Reach for it when sanity-checking a comparison your code performs, debugging why an npm range matched (or didn't), or just settling an "is this newer?" debate.

How it works

SemVer 2.0.0 defines a strict precedence: compare MAJOR, MINOR, PATCH numerically; if equal, a pre-release version (1.0.0-beta) ranks lower than the normal version (1.0.0). Within pre-release identifiers, dot-separated parts are compared - numeric parts numerically, alphanumeric parts lexically; a numeric part ranks lower than an alphanumeric.

Build metadata (+sha1234) is ignored for precedence per the spec. The comparator implements this algorithm exactly so its output matches what npm, cargo, and composer use internally.

Examples

  • Basic compare:
    1.2.3 vs 1.2.4   ->  1.2.4 is newer
    
  • Pre-release vs stable:
    1.0.0-rc.1 vs 1.0.0   ->  1.0.0 is newer
    
  • Pre-release identifiers:
    1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta
    
  • Build metadata ignored:
    1.0.0+20240101 vs 1.0.0+20250101   ->  equal precedence
    

FAQ

Why is 1.0.0-beta.11 newer than 1.0.0-beta.2?

Pre-release identifiers compare numerically when they're entirely digits, so 11 > 2. If the version uses non-numeric identifiers, lexical comparison applies.

Is 1.0.0-rc1 the same as 1.0.0-rc.1?

No - they're different identifiers. The dot-separated form (rc.1) is more common and sorts more predictably than the combined form.

What about v1.2.3?

The leading v isn't part of SemVer but is widely used as a tag prefix. Strip it before comparing - the comparator accepts it as a courtesy.

Why don't 1.0 and 1.0.0 compare?

Strict SemVer requires three components. The comparator pads missing parts with .0 (so 1.0 becomes 1.0.0) for convenience, but the spec considers 1.0 non-conformant.

Try Semantic Version Comparator

An unhandled error has occurred. Reload ×