{"success":true,"version":"v1","request":{"tool":"get_calculator_schema","calculator_id":"semver-compare"},"result":{"entity_type":"calculator","id":"semver-compare","calculator_id":"semver-compare","canonical_url":"https://tttkmbb.com/developer/semver-compare","name":"Semantic Version Comparator","title":"SemVer Comparator – Compare Two Semantic Versions with Pre-release Precedence and Caret/Tilde Range Checks","category":"developer","category_name":"Developer & IT","tool_name":"compare_semver_versions","featured_mcp_tool":false,"description":"Parses two Semantic Versioning 2.0.0 strings, orders them by the specification's precedence rules (numeric core, then pre-release identifiers; build metadata ignored) and reports whether the second version satisfies the npm-style ^ (caret) and ~ (tilde) ranges of the first.","use_when":"You need to know which of two versions is newer, whether 1.0.0-rc.1 precedes 1.0.0, or whether a dependency range such as ^1.2.3 would accept a candidate version.","do_not_use_when":"The versions are not SemVer (calendar versions, four-part Windows versions, Python PEP 440 with .post/.dev) or you need to resolve full range expressions with || and comparators.","inputs":[{"name":"version_a","label":"Version A","type":"string","required":true,"description":"First version, e.g. 1.0.0-alpha or v2.3.4+build.5 (leading v allowed).","example":"1.0.0-alpha"},{"name":"version_b","label":"Version B","type":"string","required":true,"description":"Second version to compare against A.","example":"1.0.0"}],"outputs":[{"name":"comparison","label":"Comparison","type":"string","decimals":4,"description":"A < B, A = B or A > B written with the actual version strings."},{"name":"result","label":"Result","type":"integer","decimals":4,"description":"−1 when A precedes B, 0 when they have equal precedence, 1 when A is higher."},{"name":"difference","label":"Deciding component","type":"string","decimals":4,"description":"Which part decides the order: major, minor, patch, prerelease, or equal (build metadata only, or identical)."},{"name":"parsed_a","label":"Parsed A","type":"object","decimals":4,"description":"major, minor, patch, prerelease and build of version A."},{"name":"parsed_b","label":"Parsed B","type":"object","decimals":4,"description":"major, minor, patch, prerelease and build of version B."},{"name":"is_prerelease_a","label":"A is pre-release","type":"boolean","decimals":4,"description":"true when A carries a pre-release tag."},{"name":"is_prerelease_b","label":"B is pre-release","type":"boolean","decimals":4,"description":"true when B carries a pre-release tag."},{"name":"satisfies_caret","label":"B satisfies ^A","type":"boolean","decimals":4,"description":"Whether ^A (compatible with A: same major, or same minor when major is 0) accepts B."},{"name":"satisfies_tilde","label":"B satisfies ~A","type":"boolean","decimals":4,"description":"Whether ~A (patch-level changes only: ≥ A and < next minor) accepts B."},{"name":"caret_range","label":"^A as comparators","type":"string","decimals":4,"description":"The caret range of A written as >=A <upper."},{"name":"tilde_range","label":"~A as comparators","type":"string","decimals":4,"description":"The tilde range of A written as >=A <upper."}],"input_schema":{"type":"object","properties":{"version_a":{"description":"First version, e.g. 1.0.0-alpha or v2.3.4+build.5 (leading v allowed).","type":"string","examples":["1.0.0-alpha"]},"version_b":{"description":"Second version to compare against A.","type":"string","examples":["1.0.0"]}},"additionalProperties":false,"required":["version_a","version_b"]},"output_schema":{"type":"object","properties":{"comparison":{"description":"A < B, A = B or A > B written with the actual version strings.","type":"string"},"result":{"description":"−1 when A precedes B, 0 when they have equal precedence, 1 when A is higher.","type":"integer"},"difference":{"description":"Which part decides the order: major, minor, patch, prerelease, or equal (build metadata only, or identical).","type":"string"},"parsed_a":{"description":"major, minor, patch, prerelease and build of version A.","type":"object"},"parsed_b":{"description":"major, minor, patch, prerelease and build of version B.","type":"object"},"is_prerelease_a":{"description":"true when A carries a pre-release tag.","type":"boolean"},"is_prerelease_b":{"description":"true when B carries a pre-release tag.","type":"boolean"},"satisfies_caret":{"description":"Whether ^A (compatible with A: same major, or same minor when major is 0) accepts B.","type":"boolean"},"satisfies_tilde":{"description":"Whether ~A (patch-level changes only: ≥ A and < next minor) accepts B.","type":"boolean"},"caret_range":{"description":"The caret range of A written as >=A <upper.","type":"string"},"tilde_range":{"description":"The tilde range of A written as >=A <upper.","type":"string"}}},"formula":"Precedence: compare major, minor, patch numerically; a version with a pre-release tag is lower than the same version without; pre-release identifiers are compared left to right (numeric < alphanumeric, numeric by value, alphanumeric by ASCII, shorter list lower); build metadata is ignored","method":"SemVer 2.0.0 items 9–11. Caret and tilde follow node-semver: ^1.2.3 = >=1.2.3 <2.0.0, ^0.2.3 = >=0.2.3 <0.3.0, ^0.0.3 = >=0.0.3 <0.0.4, ~1.2.3 = >=1.2.3 <1.3.0; a pre-release B only satisfies a range when A is a pre-release of the same major.minor.patch.","sources":[{"name":"Semantic Versioning 2.0.0 (semver.org)","url":"https://semver.org/spec/v2.0.0.html","type":"standard","retrieved_at":"2026-09-24"},{"name":"node-semver – Ranges, caret and tilde semantics (npm)","url":"https://github.com/npm/node-semver#ranges","type":"reference","retrieved_at":"2026-09-24"}],"freshness":{"type":"static","max_age_seconds":null,"note":"Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output."},"examples":[{"name":"1.0.0-alpha vs 1.0.0","inputs":{"version_a":"1.0.0-alpha","version_b":"1.0.0"},"expected":{"result":-1,"comparison":"1.0.0-alpha < 1.0.0","difference":"prerelease","is_prerelease_a":true,"is_prerelease_b":false,"satisfies_caret":true,"satisfies_tilde":true,"parsed_a":{"major":1,"minor":0,"patch":0,"prerelease":"alpha","build":""}},"url":"https://tttkmbb.com/api/v1/calculate/semver-compare?version_a=1.0.0-alpha&version_b=1.0.0"},{"name":"1.10.0 vs 1.9.9","inputs":{"version_a":"1.10.0","version_b":"1.9.9"},"expected":{"result":1,"comparison":"1.10.0 > 1.9.9","difference":"minor","satisfies_caret":false,"satisfies_tilde":false,"caret_range":">=1.10.0 <2.0.0","tilde_range":">=1.10.0 <1.11.0"},"url":"https://tttkmbb.com/api/v1/calculate/semver-compare?version_a=1.10.0&version_b=1.9.9"}],"faq":[{"q":"Why is 1.0.0-beta.11 higher than 1.0.0-beta.2?","a":"Numeric pre-release identifiers are compared as numbers (11 > 2), not as strings; 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0."},{"q":"Do 1.0.0+build.1 and 1.0.0+build.2 differ?","a":"Not in precedence: build metadata is ignored when ordering, so they compare as equal (result 0, difference 'equal')."},{"q":"Why does ^0.2.3 not accept 0.3.0?","a":"Below 1.0.0 the minor version is treated as the breaking level, so ^0.2.3 means >=0.2.3 <0.3.0 in npm and Cargo."}],"tags":["semver","version compare","semantic versioning","caret range","tilde range","npm version"],"related":[{"calculator_id":"cron-schedule","reason":"Another developer-tooling parser."},{"calculator_id":"text-hash","reason":"Fingerprint a release artifact."}],"links":{"html":"https://tttkmbb.com/developer/semver-compare","markdown":"https://tttkmbb.com/developer/semver-compare.md","json":"https://tttkmbb.com/developer/semver-compare.json","api":"https://tttkmbb.com/api/v1/calculate/semver-compare","schema":"https://tttkmbb.com/api/v1/calculators/semver-compare","openapi":"https://tttkmbb.com/openapi.json","mcp":"https://tttkmbb.com/mcp"},"version":"v1","updated_at":"2026-09-24"},"timestamp":"2026-09-24T03:44:12Z"}