Skip to content

Semantic Versioning

The /semver endpoint parses, bumps, and compares semantic versions following the semver.org specification.

How it works?

A version must match the official grammar MAJOR.MINOR.PATCH, optionally followed by -prerelease and +build. Leading zeros are rejected, so 01.2.3 is invalid.

Comparison follows semver precedence: numeric parts first, then the prerelease. A version carrying a prerelease ranks below the same version without one, numeric prerelease identifiers are compared as numbers (alpha.2 is lower than alpha.10), and build metadata is ignored entirely.

A bump resets the lower parts to zero and drops both the prerelease and the build metadata, so 1.0.0-alpha+build.1 bumped on patch gives 1.0.1.

A + sign decodes as a space in a query string, so the API restores it before parsing — build metadata can be sent as-is or percent-encoded.

Parameters

ParameterRequiredDescription
versionYesVersion to work with (e.g. 1.2.3-beta.1+build.42)
actionNoAction to perform: parse, bump or compare. Default: parse
partNobump only: part to increment, major, minor or patch. Default: patch
otherCond.Second version to compare against (required for compare)

Available Actions

ActionDescription
parseSplits the version into its components
bumpIncrements part and resets the lower parts to zero
compareCompares version against other using semver precedence

Response Fields

parse action:

FieldTypeDescription
versionstringThe original input version
majornumberMajor number
minornumberMinor number
patchnumberPatch number
prereleasestring|nullPrerelease identifiers without the leading -, null if absent
buildstring|nullBuild metadata without the leading +, null if absent

bump action:

FieldTypeDescription
versionstringThe original input version
actionstringbump
partstringPart that was incremented
resultstringThe bumped version

compare action:

FieldTypeDescription
versionstringThe original input version
actionstringcompare
otherstringThe version compared against
resultnumber-1 if version is lower, 0 if equal, 1 if higher
descriptionstringHuman-readable comparison (e.g. 1.2.3 < 1.3.0)

Code Examples

curl -X GET \
  "https://api.sylvain.sh/v5/semver?version=1.2.3-beta.1&action=parse"

Try It

Error Handling

If parameters are missing or invalid, the API will return an error:

Error MessageDescription
Please provide a version (?version={version})The version parameter is missing
Action must be one of: parse, bump, compareThe action value is not valid
Version must be 256 characters or fewerThe version or other value exceeds the maximum length
Invalid semver versionThe version or other value does not match the semver grammar
Part must be one of: major, minor, patchThe part value is not valid for bump
Please provide a second version (&other={version})The other parameter is missing for compare