TToolbox
1.2.3

SemVer Compare

Sort and compare semantic versions

About this tool

Semantic Versioning (SemVer 2.0.0) is the universal software release contract governing package managers like npm, Cargo, and Maven. Formatted as `MAJOR.MINOR.PATCH` with optional pre-release identifiers (`-alpha`, `-beta`, `-rc`) and build metadata (`+build.1`), SemVer communicates breaking API shifts without reading code changelogs. Version comparison cannot be modeled via raw floats (`1.10.0` is greater than `1.9.0`). This tool delivers client-side SemVer parsing, diff inspection, and multi-version sorting.

How to Use This Tool (Step-by-Step)

1

Enter Two Versions

Input Version A and Version B (e.g., `2.1.0-beta.1` vs `2.0.9`), supporting optional leading `v` prefixes.

2

Inspect Version Hierarchy Diff

The parser evaluates release precedence, declaring whether A > B, A == B, or A < B while highlighting the release delta type.

3

Bulk Sort Multi-Version Lists

Paste multiple unordered version tags to generate sorted chronological changelog release sequences with one click.

Official SemVer 2.0.0 Precedence Rules

Fully evaluates complex pre-release precedence chains (`alpha < beta < rc < stable`), aligned 100% with the official npm semver engine.

Build Metadata Invariance (+build)

Correctly ignores build metadata suffixes prefixed by `+` during version comparison, conforming to SemVer Section 10 rules.

100% Client-Side Air-Gapped

Parsing executes entirely within local browser memory. Internal proprietary release roadmaps and tags remain 100% confidential.

Release Management Best Practices & SemVer Tips

  • •Initial development under 0.y.z: Major version zero (`0.y.z`) signifies unstable experimental development; anything may change at any time.
  • •Never parse versions via `parseFloat`: `parseFloat('1.10')` becomes `1.1`, mistakenly ranking lower than `1.9`. Parse segments as independent integers.
  • •Pre-release dot separation rules: Dot-separated numeric identifiers (`-alpha.1` vs `-alpha.2`) compare numerically. Text tags compare lexically.

Code & Transformation Examples

SemVer 2.0.0 Core Bump Semantics Benchmark

Three-Tier Structure
MAJOR . MINOR . PATCH  (例如: 2 . 4 . 1)
  ↑       ↑       ↑
主版本   次版本   修订号
Release Upgrade Contract
• MAJOR (主版本号) : 当你做了不兼容的 API 破坏性变更 (Breaking Changes) 时必须递增!
• MINOR (次版本号) : 当你做了向下兼容的功能性新增 (New Features) 时必须递增!
• PATCH (修订号)   : 当你做了向下兼容的问题修复 (Bug Fixes) 时必须递增!

* Incrementing MAJOR resets MINOR and PATCH to zero (e.g., bumping 1.8.4 directly to 2.0.0).

Node.js semver Library Comparison Snippet

Node.js semver Snippet
const semver = require('semver');

// 比较大小 (gt 代表 greater than)
console.log(semver.gt('1.10.0', '1.9.0')); // true (非浮点比较!)

// 检查先行版本
console.log(semver.lt('2.0.0-rc.1', '2.0.0')); // true (正式版高于预发版)

// 验证范围满足性
console.log(semver.satisfies('1.2.3', '^1.2.0')); // true
Tilde ~ vs Caret ^ Ranges
• ~1.2.3 : 仅允许匹配同一 MINOR 的修复 (>=1.2.3 <1.3.0)
• ^1.2.3 : 允许匹配同一 MAJOR 的功能 (>=1.2.3 <2.0.0,锁定大版本不被破坏)

* The caret `^` prefix is modern npm's default, protecting against breaking API shifts while accepting feature updates.

Frequently Asked Questions

Q: Why does the stable release (1.0.0) rank higher than pre-releases (1.0.0-rc.1)?

A: SemVer rule 9 specifies that pre-release versions indicate instability. Any pre-release version has lower precedence than its stable counterpart.

Q: Is the leading 'v' prefix valid in SemVer?

A: Strictly speaking, SemVer 2.0.0 requires pure numeric starts without 'v'. However, as Git tags widely use 'v', the tool strips it gracefully.

Q: Can this tool sort hundreds of Git release tags chronologically?

A: Yes. Paste dozens or hundreds of tags from `git tag` to obtain a sorted descending release sequence in milliseconds.

Related Tools

All processing happens locally in your browser. Your data is never uploaded to a server.
/