Compare semantic version numbers to determine which is newer, older, or equal
1.2.3 and 2.0.0). Semantic Versioning (SemVer) is the de facto standard for software versioning — it gives meaning to version numbers through a strict three-part scheme: MAJOR version increments when you make incompatible API changes (breaking changes), MINOR version increments when you add backward-compatible functionality, and PATCH version increments when you make backward-compatible bug fixes. Understanding how versions compare is essential for dependency management, API compatibility checking, and automated release pipelines.2.0.0 > 1.9.9 because MAJOR 2 > 1. (2) When MAJOR, MINOR, and PATCH are equal, a pre-release version (one with a hyphen suffix like 1.0.0-alpha) has LOWER precedence than the normal version (1.0.0) — this means 1.0.0 is 'newer' than 1.0.0-beta. (3) Pre-release identifiers are compared numerically (if both are numbers) or lexically (if both are strings) — 1.0.0-alpha.1 < 1.0.0-alpha.2 < 1.0.0-beta. (4) Build metadata (the + suffix, e.g., 1.0.0+build.123) is IGNORED when determining version precedence.^1.2.3 actually resolve to the expected version?), debug CI/CD pipelines where version comparison logic determines deployment actions, and teach junior developers how semantic versioning works through interactive comparison. All comparison happens locally in your browser — your version strings, which may reveal internal release schedules, never leave your device.The SemVer 2.0.0 specification (semver.org) defines each component precisely. <strong>MAJOR (X in X.Y.Z)</strong>: increments when you make incompatible API changes. The definition of 'breaking change' is intentionally strict — any change that could cause existing code to fail, however unlikely: removing a public method, changing a function's parameter order, changing the return type, removing an exported constant, changing error behavior, or even fixing a bug that some consumers relied on (Hyrum's Law: with enough users, every observable behavior will be depended upon by someone). <strong>MINOR (Y in X.Y.Z)</strong>: increments when you add functionality in a backward-compatible manner — new methods, new optional parameters, new configuration options, deprecation warnings (but NOT removal). <strong>PATCH (Z in X.Y.Z)</strong>: increments for backward-compatible bug fixes — internal implementation changes that don't affect the public API, performance improvements that don't change behavior, security patches that don't alter interfaces. The <strong>0.Y.Z</strong> range (0.x.x) is special — anything MAY change at any time; the public API is not considered stable. The first stable release is conventionally <code>1.0.0</code>. The PivaBox Semver Comparator helps you verify version ordering against these rules.
Pre-release labels (the hyphen suffix) and build metadata (the plus suffix) serve different roles in the versioning lifecycle. <strong>Pre-release labels</strong> indicate that a version is unstable and may not satisfy the intended compatibility as indicated by its MAJOR.MINOR.PATCH numbers. Common pre-release naming conventions: <code>-alpha</code> (early internal testing, features incomplete), <code>-beta</code> (feature-complete but undergoing testing), <code>-rc</code> or <code>-rc.1</code> (release candidate, potentially final unless bugs found), <code>-dev</code> or <code>-snapshot</code> (development builds). Pre-release precedence: <code>1.0.0-alpha</code> < <code>1.0.0-alpha.1</code> < <code>1.0.0-beta</code> < <code>1.0.0-beta.2</code> < <code>1.0.0-rc.1</code> < <code>1.0.0</code>. Note that <code>1.0.0-alpha</code> is treated as <code>1.0.0-alpha.0</code> when compared against <code>1.0.0-alpha.1</code> (shorter pre-release identifier lists have lower precedence when they share a common prefix). <strong>Build metadata</strong> (e.g., <code>1.0.0+build.20240101.abcdef</code>) is completely ignored in precedence comparison — <code>1.0.0+build.1</code> and <code>1.0.0+build.2</code> are considered EQUAL versions. Build metadata is purely informational — used for CI build IDs, commit hashes, or packaging timestamps. The PivaBox comparator implements all these rules correctly.
Package managers use semver comparison to resolve version ranges into concrete versions. Common range operators: <strong>^ (caret)</strong> — compatible with the specified version: <code>^1.2.3</code> matches <code>>=1.2.3 <2.0.0</code> (allow MINOR and PATCH bumps, block MAJOR bumps that would introduce breaking changes). This is the npm default. <strong>~ (tilde)</strong> — approximately equivalent: <code>~1.2.3</code> matches <code>>=1.2.3 <1.3.0</code> (allow only PATCH bumps). More conservative than caret. <strong>>= < > <=</strong> — explicit numeric comparisons using semver precedence rules. <strong>* or x</strong> — wildcard: <code>1.x</code> matches <code>>=1.0.0 <2.0.0</code>. <strong>|| (pipe)</strong> — union of ranges: <code>1.0 || >=1.2.7 <2.0.0</code>. When you run <code>npm install</code> or <code>yarn install</code>, the package manager: (1) reads all dependency ranges from <code>package.json</code>, (2) constructs a constraint satisfaction problem (which concrete versions satisfy all range constraints simultaneously, including transitive dependencies?), (3) solves it using a SAT solver or heuristic algorithm, (4) writes the resolved concrete versions to the lockfile (<code>package-lock.json</code>, <code>yarn.lock</code>). The PivaBox Semver Comparator helps you manually verify version ordering to debug resolution issues — e.g., why does npm choose version 1.5.0 when you specified <code>^1.2.0</code>? Because 1.5.0 falls within the <code>>=1.2.0 <2.0.0</code> range and is the highest satisfying version (assuming no other constraints).