Tools / Composer Version Constraint Tester

Composer Version Constraint Tester.

Check which versions a Composer constraint like ^8.2 || ~7.4.0 accepts, with stability flags.

Runs in your browser

Ctrl/⌘ + Enter to run · Ctrl/⌘ + Shift + C to copy the result

Result
Expanded constraint
Versions
Summary

About Composer Version Constraint Tester

Composer Version Constraint Tester answers a question that comes up every time you edit composer.json: which versions will this constraint actually install? Enter a constraint and a list of versions, one per line, and the tool marks each version as matching or not and expands the constraint into the explicit ranges Composer uses internally. The caret operator allows changes that do not touch the leftmost non-zero part, so ^2.1 means at least 2.1.0 and below 3.0.0, while ^0.3 stays below 0.4.0. The tilde operator fixes everything except the last part you wrote, which surprises many people: ~1.2 allows 1.9 but ~1.2.3 stops before 1.3.0. Wildcards such as 1.2.*, hyphen ranges such as 1.0 - 2.0, comparison operators, AND with a space or comma and OR with || are all supported, as are pre-release versions like 3.0.0-RC1 and branch names like dev-main. Composer also filters by stability: with the default minimum-stability of stable, a beta or RC release is rejected even when it fits the range, unless the constraint carries a flag such as ^3.0@beta. Set minimum-stability to match your project and the table explains why a version was refused. The highest accepted version in your list is shown as the version Composer would prefer. Normalisation follows Composer's VersionParser for common forms, including the v prefix and four-part versions. It all runs in your browser.

How to Use

  1. Enter the constraint from composer.json, for example ^10.0 || ^11.0.
  2. Paste the versions to test, such as the tags of a package from Packagist, one per line.
  3. Pick your project's minimum-stability and read which versions match and why.

Frequently Asked Questions

What is the difference between ^ and ~?

^1.2.3 allows anything below 2.0.0. ~1.2.3 allows only 1.2.x, while ~1.2 allows anything below 2.0. Caret is the usual choice for libraries that follow semantic versioning.

Why is 3.0.0-RC1 rejected by ^3.0?

Composer's default minimum-stability is stable, so release candidates are skipped. Add @RC to the constraint or lower minimum-stability to accept them.

How do I match a branch?

Branches are written as dev-main or 2.x-dev. A dev-main constraint matches only that branch, and only when dev stability is allowed.

Does it query Packagist?

No. Paste the versions you want to test; the tool makes no network requests.

Related Tools