Skip to content

Semantic Version Comparator

Compare two semantic versions by precedence, including prerelease ordering and caret or tilde ranges.

Runs in your browserNo account neededFree
Loading tool…

Processing: This tool runs entirely in your browser. Your input and any file you open stay on your device — nothing is uploaded to a server.

How to use the semantic version comparator

  1. Enter two versions, with or without a leading v.
  2. Read which is newer and what kind of change separates them.
  3. Check whether the second satisfies a caret or tilde range on the first.

About this tool

Semantic versioning gives three numbers a fixed meaning: a major change may break you, a minor one adds features without breaking anything, and a patch fixes something. Comparing two versions is therefore not string comparison, and treating it as such is a live source of bugs — sorted as text, `1.0.0-rc.11` comes before `1.0.0-rc.2` and `2.0.0` comes after `10.0.0`.

The prerelease rules are where most implementations go wrong. A version carrying a prerelease tag always ranks below the same version without one, so `1.0.0-rc.1` is older than `1.0.0`. The tag itself is compared piece by piece, with numeric pieces compared as numbers and everything else as text, which is what puts `rc.11` correctly after `rc.2`.

Build metadata after a `+` is ignored entirely when ranking versions. Two releases differing only there have equal precedence, and a package manager may install either — which is why metadata is the wrong place to record anything that matters to a consumer.

Range matching is shown because it is what a package manager actually installs. A caret allows anything that does not change the leftmost non-zero number, so it tightens below 1.0.0: `^0.2.1` accepts `0.2.5` but not `0.3.0`, since a zero major version makes no compatibility promise at all.

Common uses

  • Working out whether an upgrade crosses a breaking change.
  • Checking whether a release satisfies a dependency range before pinning it.
  • Settling the order of two prerelease builds.

Frequently asked questions

Is 1.0.0-rc.2 newer than 1.0.0-rc.11?
No. Numeric prerelease pieces compare as numbers, so rc.11 is newer than rc.2, even though a plain text sort puts them the other way round.
What is the difference between a caret and a tilde range?
A tilde allows patch updates within a fixed major and minor version. A caret allows anything that does not change the leftmost non-zero number, so it usually permits minor updates too.
Does build metadata affect which version is newer?
No. The specification says metadata after a plus sign is ignored for precedence, so two versions differing only there rank equally and either may be installed.

Related tools