compare-versions

Zero-dependency semver comparison for Node.js and the browser, with support for ranges, wildcards, and Chromium-style versions.

Library
npm
v6.1.1
637stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
32/100Needs Attention
Development Activity0
Maintenance0
Community48
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
74/100Good
Architecture74
Code Quality78
Innovation60
Learning Curve82

compare-versions is a tiny, dependency-free library for comparing semantic version strings to determine which is greater, equal, or lesser. It implements the full semver specification, including versions with a varying number of segments (1, 1.0, 1.0.0), pre-release identifiers (1.0.0-alpha), wildcards (1.0.x), 4-part Chromium-style versions (25.0.1364.126), and npm-style version ranges (^1.2.3, 1.2.7 || >=1.2.9 <2.0.0).

The library exposes a small set of composable functions — compareVersions, compare, satisfies, validate, and validateStrict — and ships as ESM, CJS/UMD, and a browser global, making it usable directly in Array.prototype.sort, feature-flagging logic, or dependency-range checks without pulling in a full semver toolchain.

What You Get

  • compareVersions(v1, v2) returning -1/0/1, directly usable as an Array.sort comparator
  • compare(v1, v2, operator) for human-readable comparisons using >, <, =, >=, <=
  • satisfies(version, range) supporting npm-style semver ranges (^, ~, ||, hyphen ranges)
  • validate/validateStrict for lenient vs. strict semver-format checking
  • ESM, CJS/UMD, and browser-global builds with zero runtime dependencies

Common Use Cases

  • Sorting a list of release/version strings into semantic order
  • Gating a feature or migration behind a minimum required version check
  • Validating user- or config-supplied version strings before further processing
  • Checking whether an installed dependency version satisfies an npm-style range

Under The Hood

Architecture The library splits into single-purpose modules: utils.ts holds the shared validateAndParse/compareSegments parsing logic, and compareVersions.ts, compare.ts, satisfies.ts, and validate.ts each build a small, independent public function on top of that shared parser. index.ts simply re-exports each function, so the whole public API is composed from a handful of pure, side-effect-free functions rather than a single monolithic parser class.

Tech Stack Written in TypeScript, compiled to ESM via tsc and bundled to UMD via Rollup for the lib/umd browser/CJS build. It has zero runtime dependencies (sideEffects: false in package.json), and tests run under Mocha with c8 for coverage.

Code Quality The test/ directory maps directly onto the public API surface (compare.ts, satisfies.ts, sort.ts, validate.ts), giving each exported function its own dedicated suite. Functions are short, pure, and rely on shared parsing/validation helpers instead of duplicating segment-comparison logic across each entry point, keeping the exposed behavior consistent across compare, satisfies, and compareVersions.

API Design The API favors small, single-purpose functions over one configurable object, and documents each one with JSDoc directly in source. Since v5 the main export is named (import { compareVersions } from 'compare-versions') rather than default, aligning with modern ESM conventions, and the human-readable compare(v1, v2, '>') variant lowers the learning curve for callers unfamiliar with sort-comparator return values.

Used by 16 apps in this directory

TypeScript
94%
MIT

Actual

Invoicing Finance

28,224

Local-first personal finance with envelope budgeting, end-to-end encryption, and multi-device sync — no subscription required.

View details
93
Repo Health
85
Technical
77
Dependency
Built with
TypeScript94%
Updated yesterday
JavaScript
100%
Other

Automatisch

Automation · No Code Platforms

13,936

Self-hosted, no-code workflow automation that keeps your data on your own servers—a privacy-first alternative to Zapier with 90+ integrations.

View details
49
Repo Health
78
Technical
64
Dependency
Built with
JavaScript100%
Updated 6 months ago
JavaScript
99%
Other

ChartBrew

Analytics · Databases

4,041

Open-source reporting platform to build live dashboards from SQL, NoSQL, APIs, and SaaS tools with an AI assistant that creates charts from natural language.

View details
90
Repo Health
83
Technical
65
Dependency
Built with
JavaScript99%
Updated 6 days ago
JavaScript
90%
Other

CodeSandbox

Code Editors · Developer Tools

13,633

Instantly ready browser-based IDE that runs full npm dependency resolution and transpilation entirely client-side, with no server needed.

View details
65
Repo Health
76
Technical
63
Dependency
Built with
JavaScript90%
Updated 1 months ago
Ruby
62%
GPL 2.0

Discourse

Community

47,672

Open-source community platform with dynamic trust levels, real-time chat, and a powerful plugin architecture for self-hosted forums.

View details
89
Repo Health
89
Technical
67
Dependency
Built with
Ruby62%
JavaScript31%
Updated today
Go
83%
MIT

Gitea

Devops · Developer Tools · Project Management

57,487

Self-hosted DevOps in a single Go binary — Git hosting, GitHub Actions-compatible CI/CD, and 30+ package registries without any SaaS dependency.

View details
93
Repo Health
79
Technical
65
Dependency
Built with
Go83%
Updated today
JavaScript
99%
GPL 3.0

homepage

Monitoring · Productivity

32,092

A fast, fully static, and secure self-hosted startpage with Docker service discovery and integrations for over 160 services.

View details
91
Repo Health
86
Technical
74
Dependency
Built with
JavaScript99%
Updated today
TypeScript
89%
Apache 2.0

HyperFrames

AI Development · AI Design Tools

41,625

Turn plain HTML and CSS into deterministic, pixel-perfect MP4 videos — authored by humans or AI agents, rendered by headless Chrome and FFmpeg.

View details
82
Repo Health
83
Technical
65
Dependency
Built with
TypeScript89%
Updated today
TypeScript
76%
Other

Joplin

Note Taking

56,003

The privacy-first, open-source note-taking app with end-to-end encrypted sync, AI assistance, and a powerful plugin ecosystem across every platform.

View details
93
Repo Health
87
Technical
62
Dependency
Built with
TypeScript76%
JavaScript15%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search