Semver Range Resolver
Everyone knows the caret allows minor updates and the tilde allows patch ones. Fewer people know why 1.3.0-beta.1 is outside ^1.2.0 even though its numbers sit comfortably inside: a range admits a prerelease only when the range itself names a prerelease on the very same major, minor and patch. This resolves a range against a list of versions and gives a reason for every exclusion, so the surprising ones stop being surprising.
What this generator does
Expands the range into comparators — a caret and a tilde each become a lower and an upper bound — and tests every version against them, applying the prerelease rule and reporting the highest version that satisfies the range.
How to use this tool
- Enter the range, in the usual npm syntax.
- List the versions to test, one per line.
- Press Work it out.
- Read which versions satisfy it, and the comparator that rejected each of the rest.
Understanding the controls
- Version range
- Caret, tilde, wildcards and plain comparators all work. Spaces mean AND within a clause, and two pipes separate clauses that are combined with OR.
- Versions to test
- One per line. Prereleases are the interesting case and are welcome — each one that is excluded says whether it was the numbers or the prerelease rule that did it.
Common use cases
- Checking whether a published version satisfies a dependency range
- Understanding why a prerelease is not being picked up
- Comparing what caret and tilde actually admit on real version lists
- Working out which of your tags a consumer's range would resolve to
- Explaining semver ranges to someone with a concrete example
How this generator works
A caret pins the leftmost non-zero part, which is why ^1.2.0 allows 1.9.0 but ^0.2.0 stops at 0.3.0 — on a zero major the minor is treated as the breaking one. A tilde pins the minor. Both expand into a lower bound and an upper bound, and a range is then just a set of comparators combined with AND, with clauses combined by OR. The prerelease rule is separate and catches people out: a version with a prerelease tag satisfies a range only if some comparator in the matching clause names a prerelease on the same three numbers. Comparison itself follows the specification, including that a release outranks any prerelease of the same numbers and that numeric identifiers compare numerically rather than as text. Before display every version is re-tested against every comparator, all versions are confirmed to be accounted for as either satisfying or excluded, and the highest match is found again by sorting.
Randomness and fairness
Nothing here is random. A range and a list of versions give exactly one answer, resolved rather than sampled — the semver generator is the one that produces version numbers.
For how randomness is produced across the whole site, see how Generate Random works.
Limitations and good to know
- The npm range syntax is followed. Other ecosystems differ — Python, Ruby and Go all have their own rules and their own surprises.
- Hyphen ranges and the x-in-the-middle forms are not parsed; use explicit comparators for those.
- Build metadata after a plus sign is ignored when comparing, which is what the specification requires but is not always what people expect.
- This resolves against the versions you list. A real installer resolves against a registry and a lockfile, and can pick differently for reasons that have nothing to do with the range.
Privacy and your data
The resolution runs in your browser and the range and versions you enter are never transmitted, stored or included in analytics.
Related generators
- Semantic Version GeneratorA semantic-version-shaped string (MAJOR.MINOR.PATCH).
- Git Branch Name GeneratorGenerate an example Git branch name in the common type/description format, like feature/add-login-form.
- HTTP Status Code GeneratorA real HTTP status code with its standard meaning.
- Cron Schedule CalculatorReads a cron expression and lists the next runs, including the day-of-month and day-of-week rule people misread.