Skip to content

Main content

Netstring Length Prefix Token Tool

Calculate netstring length prefix token from explicit caller-supplied inputs.

Loading tool…

Description

Parse a canonical netstring length-prefix token.

Binary and text framing can encode a payload size, container count or terminator. Those fields describe the following data but must still be checked against its actual bytes and complete structure.

Parse a canonical netstring length-prefix token.

When to use this tool

Use Netstring Length Prefix Token when decoding one bounded framing or header component.

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 length. Use the output convention below.

Parse a canonical netstring length-prefix token. Require zero or a nonzero-leading decimal integer followed by a colon; length must be a nonnegative safe integer.1

Input fieldMeaning and unitsAccepted input
tokenTokenRequired. Text; maximum UTF-16 length 8192.
Output fieldInterpretationReturned shape
lengthDeclared byte length only; no payload or trailing comma is checked.Required. Safe integer.
json
{
  "input": {
    "token": "12:"
  },
  "output": {
    "length": 12
  }
}

Limitations and assumptions

  • No payload or trailing comma is checked, and leading-zero lengths are rejected.
  • 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 complete parser for payload validity, nested containers, text encoding and record boundaries.

References

  1. Calculation and input contract: decode/netstring-length-prefix-token — tool.io

Similar or alternative tools