Compare Semantic Versions and Check Ranges Correctly
Semantic versioning gives software releases a shared grammar: a version is written as major, minor, and patch numbers separated by dots, optionally followed by a pre-release tag after a hyphen and build metadata after a plus sign. The rules for comparing two such versions are precise, published at semver.org, and surprisingly easy to get wrong when you compare them as plain strings. This comparator implements those rules faithfully. Give it two versions and it tells you which one has higher precedence, or give it a version and a range and it tells you whether the version satisfies the range. Everything runs in your browser, so it is instant and works even offline once the page has loaded.
The precedence rules are where careful implementation matters. Comparison proceeds field by field: major, then minor, then patch, each compared as an integer, so 1.10.0 is correctly greater than 1.9.0 even though the string 1.9.0 would sort later alphabetically. When the numeric parts are equal, the pre-release tag decides the outcome, and the key rule is that a version with a pre-release tag has lower precedence than the same version without one — so 1.0.0-alpha is less than 1.0.0. Pre-release tags themselves are compared identifier by identifier: a purely numeric identifier is compared numerically and always sorts below an alphanumeric identifier, while alphanumeric identifiers are compared in ASCII order. Build metadata, the segment after the plus sign, is completely ignored for precedence, so 1.0.0 and 1.0.0 with build metadata are considered equal. Putting these together gives the canonical ordering 1.0.0-alpha, then 1.0.0-beta, then 1.0.0-rc.1, then 1.0.0, which is exactly the order in which those releases would ship.
Ranges are the other half of the tool, because in practice you rarely pin an exact version — a dependency is declared with an operator that allows a family of compatible releases. The caret operator is the most common: caret 1.2.3 allows any version that is at least 1.2.3 and below 2.0.0, meaning it accepts minor and patch updates but not a new major that could break compatibility. The tilde operator is tighter: tilde 1.2.3 allows patch updates up to but not including 1.3.0. Comparator operators such as greater-than-or-equal combine to form intervals, an x-range like 1.x accepts any version in the 1 series, a bare asterisk accepts anything, and the double-pipe joins several ranges as alternatives. Paste a version and a range and the tool evaluates the same satisfies logic that a package manager uses when it resolves your dependency tree, which turns an abstract range into a concrete yes-or-no answer.
The uses are everywhere in dependency work. A developer reviewing a lockfile can confirm whether an installed version actually falls inside the range declared in the manifest, catching a resolution surprise before it reaches production. A maintainer deciding how to publish a bugfix can check that the new patch version has higher precedence than the last release and lower precedence than the next minor. Someone auditing a security advisory can paste the affected range and their installed version to learn immediately whether they are exposed. And anyone confused about why a pre-release did not get installed can compare it against the plain release and see that the pre-release has lower precedence, which is precisely why package managers exclude pre-releases by default unless you opt in.
A few tips prevent the classic mistakes. Never compare versions as strings, because string comparison sorts 10 before 9 and treats a pre-release as greater than its release; use precedence rules instead, which is what this tool does for you. Remember that build metadata never affects ordering, so if two versions differ only after the plus sign they are equal for every practical purpose. When reasoning about a caret range, keep the special case in mind that for versions below 1.0.0 the caret is much stricter, because the leading zero signals an unstable API. Finally, if a version fails to parse, check for a missing patch number or an illegal character in the pre-release tag, since the specification requires the full major-minor-patch triple and restricts pre-release identifiers to alphanumerics and hyphens. Because the comparator runs entirely in your browser, you can check as many versions and ranges as you like with no signup and no data leaving your device.