Skip to content

Main content

Css Dimension Number Unit Split Tool

Compute css dimension number unit split from explicit bounded inputs.

Loading tool…

Description

Match a signed integer or decimal number with optional exponent followed by an ASCII letter and further letters, digits, or hyphens.

CSS token notation separates numeric values, units, Unicode ranges, and color channels. Code-point intervals differ from Unicode scalar validity, while RGB channel bytes and alpha use different scales. A token decoder can return components without parsing a stylesheet or checking all CSS semantics.

Match a signed integer or decimal number with optional exponent followed by an ASCII letter and further letters, digits, or hyphens.

When to use this tool

Use Css Dimension Number Unit Split when you need the components of the supported CSS color, range, or dimension token.

How to use the tool and how it works

  1. Enter token. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read number, unit. Use the output convention below.

Match a signed integer or decimal number with optional exponent followed by an ASCII letter and further letters, digits, or hyphens. Convert the number to a finite value and preserve the unit string.1

Input fieldMeaning and unitsAccepted input
tokenComplete literal token in the grammar stated above.Required. Text; maximum UTF-16 length 8192.
Output fieldInterpretationReturned shape
numberNumberRequired. Finite number.
unitLiteral ASCII unit identifier, with case preserved and no unit validation.Required. Text; maximum UTF-16 length 8192.
json
{
  "input": {
    "token": "-1.5em"
  },
  "output": {
    "number": -1.5,
    "unit": "em"
  }
}

Limitations and assumptions

  • The numeric grammar accepts leading-dot decimals but not a trailing decimal point. Unit names are not registered or converted, case is preserved, and CSS escapes, non-ASCII identifiers, percentages, and full tokenization are unsupported.
  • Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.

Alternative or Complementary methods

Use a CSS parser for escapes, identifiers, token boundaries, and complete stylesheet grammar. Apply appropriate color or Unicode interpretation only after checking the intended value model.

References

  1. Calculation and input contract: parse/css-dimension-number-unit-split — tool.io

Similar or alternative tools