Semver Comparator

Compare and sort semantic version strings

POST 1 credit /v1/semver-compare
curl -X POST "https://devtools.toolkitapi.io/v1/semver-compare" \
  -H "Content-Type: application/json" \
  -d '{"versions": ["2.1.0", "1.9.5", "2.0.0b1", "2.1.0rc1"]}'
import httpx

resp = httpx.post(
    "https://devtools.toolkitapi.io/v1/semver-compare",
    json={"versions": ["2.1.0", "1.9.5", "2.0.0b1", "2.1.0rc1"]},
)
print(resp.json())
const resp = await fetch("https://devtools.toolkitapi.io/v1/semver-compare", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"versions": ["2.1.0", "1.9.5", "2.0.0b1", "2.1.0rc1"]}),
});
const data = await resp.json();
console.log(data);
# See curl example
Response 200 OK
{
  "sorted": ["1.9.5", "2.0.0b1", "2.1.0rc1", "2.1.0"],
  "min": "1.9.5",
  "max": "2.1.0"
}

Try It Live

Live Demo

Description

Compare and sort semantic version strings

How to Use

1

1. Send a POST with a JSON body containing a `versions` array of version strings.

2

2. The response includes the versions sorted from lowest to highest, plus `min` and `max`.

3

3. For two-version comparisons, check the `comparison` field for a human-readable result.

About This Tool

Semver Comparator takes a list of version strings, sorts them according to PEP 440 / semantic versioning rules, and identifies the minimum and maximum versions. When exactly two versions are provided, it also returns a direct comparison result (e.g. `"1.0.0 < 2.0.0"`).

Pre-release versions (alpha, beta, rc) are sorted correctly — they always come before their corresponding release.

Why Use This Tool

Frequently Asked Questions

Which versioning scheme is used?
PEP 440 via Python's `packaging.version.Version`. This handles standard semver (1.2.3), pre-releases (1.0.0a1, 1.0.0b2, 1.0.0rc1), post-releases, and dev versions.
What happens with invalid version strings?
An error is returned listing the invalid version strings.
Can I compare more than two versions?
Yes. Pass up to 100 versions and they will all be sorted. The `comparison` field is only included when exactly two are provided.

Start using Semver Comparator now

Get your free API key and make your first request in under a minute.