Guide

How to unwrap JSON encoded inside JSON strings

ToolboxKit maintainer · Published July 22, 2026 · Updated July 22, 2026

A payload can be valid JSON while still hiding its useful structure. This happens when a field contains another JSON document serialized as a string, often after passing through a queue, database column, webhook envelope, or log formatter.

Before and after

{"payload":"{\"flag\":\"true\",\"items\":\"[1,2,3]\"}","source":"queue"}

After recursive unwrapping:

{
  "payload": {
    "flag": true,
    "items": [1, 2, 3]
  },
  "source": "queue"
}

Why one parse is not enough

The first parse creates the outer object, but payload is still a string. A safe recursive pass tests string values with the JSON parser and then descends into any resulting object or array. Multiple encoding layers require repeating that step until the value stops changing or a depth limit is reached.

Primitives are part of the contract

Valid JSON strings may encode more than containers. JSON Utils converts "true", "123", "null", and quoted JSON strings when they parse cleanly. It preserves ordinary text such as hello world and almost-JSON such as {not json}.

Trust boundary

Recursive decoding should be bounded. Toolbox Tools caps nesting depth and string passes, limits total input size, and leaves invalid strings untouched. It does not infer a schema or repair arbitrary broken text, because silent over-transformation makes debugging output harder to trust.

Privacy and use

Encoded text can still contain secrets and personal data. Redact production samples before pasting them. The normal transformation runs locally in the browser.

Open JSON Utils