Semantic Version Validator

Paste a version string to validate it against the SemVer 2.0.0 spec.

Result

Yes
2
4
1
beta.3
build.20240115

How it is calculated

After trimming spaces from both ends, the string is matched against the official SemVer 2.0.0 pattern: MAJOR.MINOR.PATCH[-PRERELEASE][+BUILD]. MAJOR, MINOR and PATCH must be non-negative whole numbers with no leading zeros (0 is fine, 01 is not). The optional pre-release part follows a hyphen and is made of dot-separated identifiers using letters, digits and hyphens, where purely numeric identifiers also may not have leading zeros. The optional build part follows a plus sign and uses the same characters, but leading zeros are allowed there.

If the match succeeds, each part is shown separately and an absent part is displayed as a dash. If it fails, the string is reported as invalid and every field shows a dash. The tool only checks the format; it does not compare two versions or tell you which is newer.

Worked example

Input: 2.4.1-beta.3+build.20240115. The core before any hyphen or plus is 2.4.1, so major = 2, minor = 4, patch = 1. The text after the first hyphen and before the plus is the pre-release, beta.3, made of the identifiers “beta” and “3”. The text after the plus is the build metadata, build.20240115. Every rule is satisfied, so the validity result is Yes and all five parts are filled in.

Try this example →

Common mistakes

  • Adding a “v” prefix (v1.2.3). It is common in git tags, but the SemVer grammar does not allow it, so the tool reports it as invalid. Strip the “v” first.
  • Writing only two parts (1.2). SemVer always requires major, minor and patch, so a missing patch makes the string invalid.
  • Padding numbers with zeros, such as 1.02.3 or 1.0.0-01. Leading zeros are rejected in the core numbers and in numeric pre-release identifiers.
  • Leaving a trailing hyphen or plus (1.2.3- or 1.2.3+). An empty pre-release or build section is not allowed.
  • Expecting build metadata to matter when ordering versions. It is accepted and displayed here, but SemVer says it is ignored when comparing precedence, and this tool does no comparison at all.

About this calculator

Semantic Versioning 2.0.0 (semver.org) is the widely adopted spec — used by npm, Cargo, Composer, and most modern package registries — for structuring version numbers as MAJOR.MINOR.PATCH, where major increments signal breaking changes, minor increments add backward-compatible features, and patch increments are backward-compatible fixes, optionally extended with a hyphenated pre-release tag (like -beta.1) and a plus-prefixed build metadata tag (like +20130313144700).

This tool checks whether a pasted version string is valid under the SemVer 2.0.0 grammar and, if so, breaks it into its major, minor, patch, pre-release, and build components. Software developers publishing packages, CI/CD pipeline maintainers validating release tags, and package registry tooling authors use it to catch malformed version strings before they cause a broken publish or a dependency-resolution failure.

Was this helpful?

You can pick up to 3 reactions.

Comments

  • Be the first to comment.

Popular calculators

All Calculators