Description
Parse jsonString, require a string value, and return its decoded JavaScript length as utf16Units.
JSON strings use escape syntax, while decoded JavaScript strings are sequences of UTF-16 units. A supplementary Unicode scalar occupies a surrogate pair, and a lone surrogate is not a complete scalar.
Parse jsonString, require a string value, and return its decoded JavaScript length as utf16Units.
When to use this tool
Use JSON String Utf16 Unit Count when you need a decoded UTF-16 or normalization diagnostic.
How to use the tool and how it works
- Enter jsonString. Use the units and conventions below.
- Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
- Read utf16Units. Use the output convention below.
Parse jsonString, require a string value, and return its decoded JavaScript length as utf16Units.1
| Input field | Meaning and units | Accepted input |
|---|---|---|
| jsonString | Json String | Required. Text; maximum UTF-16 length 8192. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| utf16Units | Utf16 Units | Required. Safe integer. |
{
"input": {
"jsonString": "\"A🚀\""
},
"output": {
"utf16Units": 3
}
} Limitations and assumptions
- The count excludes JSON quotes and escape spelling; supplementary characters occupy two UTF-16 units.
- 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 Unicode-aware text processing and a full JSON parser when decoding, comparing, or repairing complete documents.
References
Similar or alternative tools
- JSON String Tab Versus Space Lexeme
Parse lexeme as a string, count decoded tab and space code points, and return decodedLength in UTF-16 units.
- JSON String Escape Length Budget
Serialize value as a JSON string and return source UTF-16 length, complete serialized length, and their difference as overhead.