DevTools Logo

SemVer Range Intersection

SemVer Range Intersection

Find the versions shared by npm dependency ranges, entirely in your browser.

Dependency ranges

Use ^, ~, comparators, x-ranges, hyphens, ||, and spaces for AND.

Examples

Overlapping caret and bounded range

Input
["^1.2.0", ">=1.5.0 <2.0.0"]
Output
empty: false, lower: >= 1.5.0, upper: < 2.0.0

The bounded range tightens the caret lower bound from 1.2.0 to 1.5.0 while the <2.0.0 ceiling survives.

Disjoint majors are empty

Input
["^1.0.0", "^2.0.0"]
Output
empty: true, reason: Ranges do not overlap

No version satisfies both >=1.0.0 <2.0.0 and >=2.0.0 <3.0.0, so the tightest bounds invert and the result is empty.

About this tool

SemVer Range Intersection parses npm-style ranges with parseRange and tests versions with satisfies. parseVersion accepts an optional v/= prefix and partial core components, rejects wildcards and unsafe integers (so 1.2.03 is null), and validates prerelease identifiers including the no-leading-zero numeric rule. Supported range syntax includes comparators (<, <=, >, >=, =), caret (^ with 0-major pinning: ^0.2.3 admits 0.2.9 but not 0.3.0, and ^0.0.3 admits only 0.0.3), tilde (~ pinned below the next minor), x/* wildcards (1.2.x means >=1.2.0 <1.3.0), inclusive hyphen ranges (1.2.3 - 2.0.0 admits both endpoints), space-separated AND, and || OR branches parsed into separate RangeSets.

Prerelease versions are isolated the npm way: satisfies returns false for a prerelease unless at least one comparator in the matched set carries a prerelease with the same major.minor.patch (so 1.2.3-beta.1 fails >=1.0.0 <2.0.0 but passes >=1.2.3-beta.0 <1.2.3, and 1.2.3-beta.1 passes its exact pin). Comparison follows semver precedence with numeric identifiers ordered numerically, numeric below alphanumeric, and a missing prerelease ranking above any prerelease. Invalid range text throws (Range is empty, Invalid range, Invalid range token), and satisfies treats unparseable input as false rather than throwing.

intersectRanges requires at least two range strings, expands every || combination across inputs, and intersects each combination by keeping the tightest lower bound (>, >=, =) and upper bound (<, <=, =). Equal bounds with any exclusive side, inverted bounds, or prerelease-only contact produce empty: true with a reason such as Ranges do not overlap. A successful result reports empty: false with the winning lower/upper bounds — for example ^1.2.0 with >=1.5.0 <2.0.0 yields lower 1.5.0 — while solveIntersection accepts either an array or newline-separated text and funnels it into the same engine.

How to use this tool

  1. Enter two or more ranges

    Provide one range per line or array entry using ^, ~, x-ranges, hyphen, comparators, spaces for AND, and || for OR. A single range throws: at least two are required.

  2. Read the intersection verdict

    A non-empty result names the tightest inclusive/exclusive lower and upper bounds; an empty result carries a reason such as Ranges do not overlap or an invalid-token message.

  3. Spot-check versions with satisfies

    Test candidate versions against each range, remembering that prereleases only match prerelease-aware comparators on the same triple.

  4. Resolve OR branches

    When a range contains ||, check which alternative overlaps: ^1.0 || ^3.0 intersected with ^3.2.0 succeeds through the ^3.0 branch while ^2.0.0 alone stays empty.

Use cases

Reconciling dependency constraints

Check whether two peer or engine ranges admit any common version before merging branches or publishing.

Auditing caret and tilde upgrades

Confirm that ^0.0.3 pins to a single patch while ^1.2.0 floats, so lockfile churn matches expectations.

Gating prerelease channels

Verify that a beta tag is excluded from plain ranges and only admitted by a prerelease-pinned comparator.

Common mistakes

Mistake:Assuming ^0.0.3 behaves like ^1.2.3.

Fix:Zero-major carets pin harder: ^0.0.3 means >=0.0.3 <0.0.4, so 0.0.4 already falls outside. Read the zero-major rule before widening the range.

Mistake:Expecting a prerelease to satisfy a plain range.

Fix:Prereleases are excluded unless a comparator names a prerelease on the same triple. Pin or widen the comparator (e.g. >=1.2.3-beta.0 <1.2.3) when prereleases must match.

Mistake:Passing a single range or empty text to the intersector.

Fix:Supply at least two non-empty ranges; one input throws and empty text fails parsing. Use satisfies for single-range membership tests.

Frequently asked questions

What does this tool do?

It intersects two or more npm-style semver ranges (^, ~, x/*, hyphen, comparators, space AND, || OR) and reports either the tightest surviving lower/upper bounds or empty: true with a reason; it also tests individual versions with satisfies.

Why doesn't my prerelease match, and how do zero-major carets behave?

Prereleases are isolated: 1.2.3-beta.1 fails >=1.0.0 <2.0.0 but passes a prerelease-aware comparator on the same triple such as >=1.2.3-beta.0 <1.2.3. Zero-major carets pin harder than ^1.x — ^0.2.3 admits 0.2.9 but not 0.3.0, and ^0.0.3 admits only 0.0.3 — and hyphen bounds are inclusive on both ends.

Is my range data uploaded or stored?

No. Parsing, precedence comparison, and bound intersection are pure client-side computation — ranges and versions never leave your browser.

How do I reconcile two dependency constraints?

Enter one range per line: ^1.2.0 with >=1.5.0 <2.0.0 reports non-empty with lower 1.5.0, while ^1.0.0 with ^2.0.0 reports empty (Ranges do not overlap). For || ranges the engine tries every branch combination and keeps the first overlapping one.

References & standards

.env Secret Safety Linter

Validate .env syntax and spot likely leaked credentials or placeholder secrets.

.htaccess Generator

Build an Apache .htaccess — HTTPS redirects, rewrites, error pages, security headers, and basic auth

2D Fluid Dynamics & Particle Physics Sandbox

A physics playground with two engines sharing one canvas. The fluid mode runs a real Eulerian Navier-Stokes solver — semi-Lagrangian advection, explicit diffusion, Jacobi pressure projection and vorticity confinement — that you paint with dye and velocity using mouse or touch. The particle mode is a damped Verlet N-body engine with gravity wells, Coulomb attractors and repulsors, spring links, wall restitution and elastic circle collisions. Particle counts adapt to the device (100k target on WebGL2 desktop, 2k-5k on CPU fallback), and every configuration exports as runnable code: a Matter.js world, a PixiJS ticker setup, or a standalone vanilla Canvas engine.

AI Function Calling Schema Generator

Generate function calling JSON schemas from TypeScript interfaces

Algorithm Arena & Data Structure Visualizer

Interactive arena for algorithms and data structures: eight sorting algorithms racing on one seeded input, six pathfinding algorithms walking generated mazes, and BST, AVL, Red-Black, B-tree, heap and trie operations replayed step by step with rotations highlighted. Every run shows the Big-O table and the phase-highlighted reference implementation in four languages, and compared values can be played as pitch (sonification) through the shared audio engine. Everything runs client-side; inputs never leave the browser.

Ansible Playbook Generator

Build an Ansible playbook — hosts, vars, and tasks with modules — as YAML