Semver Validator & Comparator
Validate two version strings and compare them with the semantic versioning precedence rules.
What is Semver Compare?
A semantic version validator and comparator. It checks both strings against the spec and then applies the precedence rules identifier by identifier, which is the only way to answer questions like whether 1.0.0-alpha.2 or 1.0.0-alpha.10 is newer.
How it works
After a strict parse, major, minor and patch are compared numerically. If they tie, prerelease identifiers are compared: numeric ones numerically, alphanumeric ones lexically with numeric always lower, and a version with a prerelease always below the same version without one. Build metadata is ignored for precedence, so two different strings can compare equal — which the tool says explicitly instead of pretending they are identical.
- Paste or fill in the input. Drop in a commit message, a diff, a package.json, a path list or a set of options. The tool reads it locally — nothing is uploaded and no repository is contacted.
- Adjust the rules to match your project. Every linter here takes its convention from a setting you can change: allowed commit types, header length, target branch length, known branch names. Set them once to what your team actually uses.
- Copy the result. Generated files copy straight to the clipboard or download as a real file with the right name (.gitignore, CODEOWNERS, LICENSE, COMMIT_EDITMSG), and Reset returns every field to its default.
Examples
A commit message that fails CI
"Updated(auth): Fixed the expired-token redirect." is rejected by release automation and reported here with the exact reasons: unknown type, capitalised description, past tense and a trailing period.
A .gitignore that only half works
The Checker shows which rule decides a path — and why `!keep.txt` inside an ignored directory never fires, the mistake that sends people to Stack Overflow.
A dependency bump nobody reviewed
The package.json Diff separates added, removed and changed entries per section, so a caret bump of a runtime dependency does not hide inside a lockfile-sized pull request.
A diff pasted from a code review comment
The Diff Viewer understands several `diff --git` blocks, mode-only changes, renames and binary stubs, and calls out a pasted `--stat` summary instead of rendering an empty box.
Common mistakes
Committing a .gitignore without checking it
Rules look right and behave differently: a pattern containing a slash is anchored to the root, a trailing slash means directories only, and a file inside an ignored directory cannot be re-included. Check the paths that matter before you commit the file.
Rewriting published history
A clean commit history is worth having, but amend, rebase and filter-repo change commit hashes. Only rewrite commits that nobody has pulled; after a rewrite, push with --force-with-lease rather than --force.
Treating a generated file as if it were reviewed
These tools produce a starting point, not a decision. Check the licence text against the canonical source, read the security policy before publishing it, and make sure a CODEOWNERS team actually exists — GitHub silently ignores rules whose owner has no write access.
Putting slow checks in a pre-commit hook
A hook that takes 30 seconds gets bypassed with --no-verify within a week, and then it protects nothing. Keep pre-commit to formatting and linting, move type checks and tests to pre-push or CI.
Frequently asked questions
Why do 1.2.3+build.1 and 1.2.3+build.2 compare equal?
The spec says build metadata is ignored when determining precedence, so they are the same version ordered equal. npm treats them as the same version too, which is why build metadata is a poor place for anything meaningful.
Is 1.0.0-alpha newer than 1.0.0-alpha.1?
No — a larger set of identifiers wins when all the preceding ones are equal, so 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0.
How do I check whether a version satisfies a range like ^1.2.3?
Ranges are a separate grammar from versions. The package.json validator evaluates caret, tilde, comparator, x-range, hyphen and || ranges for every dependency spec you paste.