Version String Parser

StrictSemVer2three-numericcomponents/prerelease/buildparser,no coercion/comparison or arbitraryvendorversionmeaning. Explicitboundedofflineconvention,not authoritative external identity,eligibility,clinical or safe-use determination.

Description

Semantic Versioning separates a release into major, minor and patch numbers with optional prerelease and build identifiers.

Semantic Versioning separates a release into major, minor and patch numbers with optional prerelease and build identifiers.1, 2

This strict parser exposes those parts and does not accept a v prefix, fill in missing components or compare release precedence.

When to use Version String Parser

Use this tool to apply the stated version string parser operation with an explicit input and unit basis.

How to use Version String Parser and how it works

  1. Establish the text or game convention described above.
  2. Enter actualVersionText and run the tool.
  3. Read result.major, result.minor, result.patch, result.prerelease, result.build using the output meanings below.
  4. If input is rejected, correct the stated type, range, ordering or alignment issue and rerun; review successful results under the declared convention.
Input fieldMeaningValue typeRequirement
actualVersionTextVersion Text. Units, ordering and applicable branch are specified in the algorithm.stringrequired; further conditions in the algorithm

Match the canonical SemVer 2.0.0 three-number syntax with no leading zeros in core numbers or purely numeric prerelease identifiers. Require core components to fit JavaScript safe integers; return absent prerelease and build metadata as empty strings. Build numeric identifiers may have leading zeros.

version = major.minor.patch[-prerelease][+build]

Apply the declared units, ordering and branch conditions.

Output fieldMeaningValue type
resultObject containing the declared output fields.object
result.majorMajor version component as a nonnegative safe integer.number
result.minorMinor version component as a nonnegative safe integer.number
result.patchPatch version component as a nonnegative safe integer.number
result.prereleasePrerelease identifier text, or an empty string if absent.string
result.buildBuild metadata text, or an empty string if absent.string
json
{
  "input": {
    "actualVersionText": "1.2.3-alpha.1+build.7"
  },
  "output": {
    "result": {
      "major": 1,
      "minor": 2,
      "patch": 3,
      "prerelease": "alpha.1",
      "build": "build.7"
    }
  }
}

Limitations and assumptions

The output applies the declared operation to the values you supply. Establish the measurement basis, units, coefficients and any caller-selected rules before interpreting it. The tool does not independently collect or verify observations or decide whether a model or reference applies.

Supply explicit required fields with the documented types and dense aligned arrays. Unknown fields, wrong types and nonfinite numbers are rejected. Branch-specific constraints are explained above. A returned boolean, signed difference or tied result follows the stated convention; an input error instead means the required input contract was not satisfied. Very large inputs or outputs may be rejected by shared resource limits.

The SemVer specification defines core numbers, prerelease identifiers and build metadata. This parser enforces that syntax and adds a safe-integer limit for the three numeric components.

Alternative or Complementary methods

Use Semantic Version Comparator for the related operation. Compare two supplied versions by precedence; build metadata is ignored.3

Use Semantic Version Range Checker for the related operation. Check a version against the supported conjunction of range comparators.4

References

  1. Version String Parser — tool.io

  2. Semantic Versioning 2.0.0 — Semantic Versioning

  3. Semantic Version Comparator — committed implementation — tool.io

  4. Semantic Version Range Checker — committed implementation — tool.io

Similar or alternative tools

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies