JSON String Byte Budget Audit
Audit decoded JSON string values against a UTF-8 byte limit; counts Unicode replacement encodings for unpaired surrogates, not serialized JSON escape bytes.
Description
Audit decoded JSON string values against a UTF-8 byte limit; counts Unicode replacement encodings for unpaired surrogates, not serialized JSON escape bytes.
A JSON string can occupy more UTF-8 bytes than its visible character count suggests. This audit locates string values that exceed a byte budget, so multilingual content can be checked before transfer or storage.
When to use this tool
Audit decoded JSON string values against a UTF-8 byte limit; counts Unicode replacement encodings for unpaired surrogates, not serialized JSON escape bytes.
- Prepare the supplied documentJson, maximumUtf8Bytes fields for this operation.
- Compare the complete example with the representation used by your own input before carrying the result into another step.
How to use the tool and how it works
- Enter documentJson, maximumUtf8Bytes. Use the exact text syntax, units and index conventions explained below.
- Run the tool. If input validation fails, correct the supplied fields before interpreting any result.
- Read result.violations. Interpret false, null and empty lists using the distinctions below; they can be valid outputs.
Parse documentJson and walk scalar leaves. For each string, count its UTF-8 bytes and report its JSON Pointer, byte count and excess only when the count is strictly above maximumUtf8Bytes. The root pointer is empty text; a limit of zero is allowed.1
| Input field | Meaning and representation | Accepted input |
|---|---|---|
| documentJson | JSON text, entered as one text field. The decoded structure is illustrated below; it is not a separate file. | Text |
| maximumUtf8Bytes | maximum utf8 bytes. | Integer from 0 to 1000000 inclusive |
For the JSON text fields, the following decoded structures show the example records before they are serialized into input strings. Keep field names, list nesting and value types as shown.
[
{
"field": "documentJson",
"decoded": {
"a": "\ud83d\ude00"
}
}
] | Output field | Interpretation |
|---|---|
| result | Object containing the named outputs below. |
| result.violations | The violations list in the ordering and representation described above. |
{
"input": {
"documentJson": "{\"a\":\"\ud83d\ude00\"}",
"maximumUtf8Bytes": 3
},
"output": {
"result": {
"violations": [
{
"path": "/a",
"utf8Bytes": 4,
"excess": 1
}
]
}
}
} Limitations and assumptions
- Object keys and JSON punctuation are not measured. The budget applies separately to decoded string values, rather than the complete serialized document.
- Decoded JSON is bounded to 20,000 nodes and 32 nesting levels; record arrays have at most 128 records. Parsed number values use JavaScript floating point rather than arbitrary-precision decimal arithmetic.
- Every declared top-level field is required and unexpected fields are rejected. Numeric inputs must be finite; ordinary text fields are bounded to 8,192 UTF-16 code units, with tighter operation-specific limits where stated.
- Ordinary string lists have at most 128 entries of at most 128 code units each; numeric lists and matrices have separate bounded size checks. Nonfinite results and excessively large serialized outputs are rejected.
- Indexes are zero-based and spans have an exclusive end unless explicitly stated otherwise. A valid false, null or empty-list result is distinct from malformed input.
Alternative or Complementary methods
For document-wide requirements, combine these structural inventories with an explicit JSON Schema. Preserve the distinction between missing properties and null values, and between numbers and numeric-looking strings when building joins or indexes.
References
Similar or alternative tools
- json all or none key presence
Check all-or-none own member presence for an explicit key group; absent versus null is preserved.
- JSON Array Homogeneity Audit
Audit immediate element-type homogeneity for every JSON array; an empty array is vacuously homogeneous, not evidence of a particular type.