JSON Escape & Unescape · Tutorial

How to read escaped JSON from a log file

5 min readbeginnerUpdated

Many logging and monitoring tools record a JSON payload as a single escaped string, so a useful error report ends up looking like "{\"level\":\"error\",\"msg\":...}". This tutorial shows how to copy that string out of a log, unescape it into readable JSON, and pick out the details you need.

What you need

  • The JSON Escape & Unescape tool, switched to Unescape
  • A log line containing escaped JSON (the Try it button loads a payment error)

Steps

  1. Copy just the escaped value

    In your log viewer, find the field that holds the escaped JSON. It usually starts with "{\" or {\". Copy from the first { (or the quote before it) to the last } (or the quote after it). The surrounding quotes are optional.

  2. Paste it into the tool

    Paste into the left box. The tool removes every backslash escape and shows the original text. For the sample, a green note confirms the result is valid JSON.

  3. Read the formatted result

    Because the result is JSON, it is pretty-printed automatically. In the sample you can now see at a glance that the payments service logged Card declined for order 4471, with decline codes 05 and 51, and that no retry was attempted.

    {
      "level": "error",
      "service": "payments",
      "msg": "Card declined",
      "context": {
        "orderId": 4471,
        "retry": false,
        "codes": ["05", "51"]
      }
    }
  4. Explore larger payloads

    For long or deeply nested payloads, copy the result into the JSON Formatter Tree tab to browse it as a collapsible tree and copy the path to any field.

  5. Handle double escaping

    If the result still contains \", the log escaped the payload twice. Copy the output, paste it back into the left box, and unescape again. Each pass removes one layer.

Try it yourself

Opens the JSON Escape & Unescape with this tutorial's sample loaded.

Try it now

Common mistakes

Copying part of the line
If you start or stop in the middle of the value, the tool reports an unescaped quote or a broken escape. Copy the whole value, from its first brace to its last.
Including the log prefix
Timestamps and log levels in front of the JSON are not part of the string. Remove them before pasting.
Sharing logs that contain personal data
Unescaped logs are easy to read, for anyone. Remove customer details and tokens before sharing a payload in a ticket or chat.

Next steps

Go back to the JSON Escape & Unescape, or keep going with one of these:

FAQ

Why do logging tools escape JSON at all?

Many log formats are themselves JSON, with one field per line. To store another JSON document in a field without breaking the line, it has to be written as an escaped string.