Skip to content

Development

SemVer Comparator

Compare, validate, sort and evaluate semantic versions and npm-compatible ranges.

Loading tool…

Find this tool in

Helpful references

About this tool

What is SemVer Comparator?

Compare version precedence or check a version against a supported range before changing a dependency. Semantic versions have major, minor and patch components plus optional prerelease and build information. A newer-looking label does not establish compatibility with your application or the safety of an update.

A worked example

Put a prerelease before its final release

Example input

1.2.3-alpha.1
1.2.3

Expected result

1.2.3-alpha.1 < 1.2.3

Compare these as semantic versions rather than sorting plain text. The prerelease precedes the release with the same three numeric components. Build metadata does not determine precedence. Range matching has its own prerelease rules, so test the actual target version against the actual range instead of inferring the answer from this comparison.

Common mistakes and limits

  • A vendor's calendar version or arbitrary release label may not follow semantic versioning. Do not force it into a comparison with a different scheme.
  • A satisfying dependency range is not evidence that an update has no breaking behavior. Read release notes and run the application's checks.

Features

What you can do

  • Compare two semantic versions.
  • Identify major, minor, patch and prerelease differences.
  • Inspect parsed major, minor and patch components.
  • Display prerelease identifiers and build metadata.
  • Check whether a version satisfies an npm-compatible range.
  • Show the minimum version accepted by a range when available.
  • Sort version lists in ascending or descending order.
  • Load built-in comparison examples.
  • Perform every operation locally in your browser.

Frequently asked questions

Questions about SemVer Comparator

What is Semantic Versioning?

Semantic Versioning uses versions in the form major.minor.patch. Major releases introduce incompatible changes, minor releases add backward-compatible functionality and patch releases contain backward-compatible fixes.

How are prerelease versions compared?

A prerelease version has lower precedence than the associated stable version. For example, 2.0.0-beta.1 is older than 2.0.0.

Does build metadata affect version precedence?

No. Build metadata following a plus sign does not affect Semantic Versioning precedence.

Which version range syntax is supported?

The range checker supports npm-compatible syntax such as caret, tilde, comparison operators, wildcards and combined ranges.

Can I sort versions separated by commas?

Yes. Enter one version per line or separate multiple versions with commas.

Are versions sent to a server?

No. Parsing, comparison, range evaluation and sorting happen locally inside your browser.

Related tools