SemVer Version Comparator & Range Tester

Which version is newer? Does ^2.3.1 accept 2.9.0? Paste your versions and ranges — get the answer and a plain-language breakdown of the rules.

—
Embed this tool on your website / blog No code required · Copy and paste
HTML Embed Code (iframe):
<iframe src="https://lucentool.com/semver-compare" width="100%" height="650" style="border:1px solid #e5e0d8;border-radius:12px;max-width:850px;width:100%;" frameborder="0"></iframe>
<div style="font-size:12px;color:#78716c;margin-top:6px;font-family:sans-serif;">Powered by <a href="https://lucentool.com/semver-compare" target="_blank" style="color:#c85a32;text-decoration:none;">Lucentool - SemVer Version Comparator & Range Tester</a></div>

Semantic versioning in one minute

SemVer is MAJOR.MINOR.PATCH: bump MAJOR for breaking changes, MINOR for backward-compatible features, PATCH for bug fixes. Pre-release tags (-beta.2, -rc.1) sort before the final release. Comparison is numeric, segment by segment, left to right — 2.10.0 > 2.9.9 because 10 > 9, never string order.

Range operators

Why it matters

Lockfiles and package managers resolve ranges every install. Knowing what ^ actually allows — and that ^0.x behaves like ~0.x — prevents surprise upgrades (or missing security patches) in your dependencies.

Formats, sizes and other limits

parseVer() splits a version into major, minor and patch numbers, an optional pre-release tag and build metadata using one anchored regular expression, so a malformed version is rejected rather than half-understood. compare() then compares numerically field by field and, when the numeric parts tie, falls back to pre-release rules — a version with a pre-release tag sorts before the same version without one. verMatchesRange() splits on || for alternatives, treats whitespace between comparators as AND, and singleMatch() applies one comparator such as caret, tilde, or a bare version.

Where it stops working

The range grammar implemented here is the common subset, not npm's full resolver: aliases such as npm:, file: and git+ URLs, workspace protocols and dist-tags are not understood, and || combined with hyphen ranges can differ from what npm decides. Pre-release matching is the other soft spot — npm only considers pre-releases when the range itself mentions one, and a reimplementation can drift on that detail.

Privacy: nothing is uploaded

Version strings are compared with local string and number operations. No registry is queried, so the page cannot leak which packages you are investigating.

Frequently asked questions

Does ^1.2.3 include 2.0.0?

No. A caret range allows changes that do not modify the left-most non-zero digit, so ^1.2.3 stays below 2.0.0 but accepts 1.9.9.

Why does npm resolve differently?

Because npm's resolver supports aliases, workspace protocols and dist-tags that this page does not parse. For a lockfile-level answer, ask npm.

How do pre-release versions sort?

A pre-release sorts before its release: 1.0.0-rc.1 is lower than 1.0.0. Numeric identifiers compare numerically, alphanumeric ones lexically.