๐Ÿท๏ธ Semantic Version Checker

1.2.3 is older than 1.10.0-beta.1

Enter two version numbers in semantic versioning format (e.g. 1.2.3, 2.0.0-beta.1), and this tool automatically determines which one is newer. Pre-release versions (-beta, -alpha, etc.) are compared correctly according to the semver spec. Handy for managing npm package versions or checking release ordering.

How to use

  1. Enter the two version numbers you want to compare.
  2. Which version is newer (greater) is determined and shown automatically.
  3. An input field turns red if the version format is invalid.

How the calculation works

Semantic Versioning (SemVer 2.0.0) writes software versions as MAJOR.MINOR.PATCH: bump MAJOR for incompatible changes, MINOR for new features and PATCH for bug fixes. This tool validates the format with the official regular expression from semver.org, then compares two versions: 1. Compare major, minor and patch as numbers (1.10.0 is newer than 1.9.0). 2. If equal, a version with a pre-release tag (-alpha and so on) is older. 3. Pre-release tags are compared identifier by identifier (split at "."): numeric identifiers as numbers, others as strings, and numeric identifiers sort before alphanumeric ones. Build metadata (after "+") is ignored for comparison. Leading zeros such as "01.2.3" are invalid in SemVer.

Worked example

1.2.3 vs 1.10.0-beta.1 Minor 2 < 10, so 1.2.3 is older The ordering example from the SemVer spec (oldest first) 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0 beta.2 and beta.11 are compared numerically: 2 < 11.

Things to be aware of

  • A leading "v" (v1.2.3) is common but not part of the SemVer format, so it is rejected here. Remove the v.
  • npm ranges such as ^1.2.3 and ~1.2.3 are not handled.
  • 1.0.0+build.1 and 1.0.0+build.2 compare as equal because build metadata is ignored.

FAQ

What is semantic versioning?

It's a convention for managing versions in the form "major.minor.patch" (e.g. 1.2.3) โ€” bump major for breaking changes, minor for backward-compatible features, and patch for bug fixes.

How are pre-release versions compared?

For the same major.minor.patch, a pre-release version (e.g. 1.0.0-beta) is treated as older than the corresponding release version (1.0.0).

Does build metadata (the +build.1 part) affect the comparison?

No, per the semver spec, build metadata is not used when comparing version precedence.