Double-Encoded JSON – Detect and Decode JSON Stringified Twice

Double-encoded JSON is valid JSON text whose parsed result is another serialized JSON string. The symptom is often extra backslashes and quotes around an object that should already be structured data.

Runs locally
Ready to repair

Paste malformed JSON or AI-generated structured output.

36 chars

Run the repair to preview the corrected document.

0 chars

Try a focused case

Common invalid JSON examples

Load one broken syntax pattern at a time, run the repair, and compare the declared rule with the resulting repair log.

Trailing commas

Trailing comma

Remove commas that appear immediately before closing object or array delimiters without touching commas stored inside string values.

{"roles":["admin","editor",],"active":true,}

Review: Confirm that each removed comma was only formatting punctuation and did not represent an intentionally missing value.

JavaScript-style object

Trailing comma · Single-quoted string · Unquoted object key

Convert identifier-like keys and single-quoted strings from a JavaScript object literal into standard JSON syntax.

{
  name: 'VetaTool',
  features: ['repair', 'diff',],
}

Review: Review every inferred key and string boundary because apostrophes and JavaScript escaping can make the intended text ambiguous.

JavaScript comments

JavaScript comment

Remove line and block comments that are legal in some configuration formats but are not allowed by the JSON grammar.

{
  // feature flag
  "enabled": true /* temporary rollout */
}

Review: Check whether a removed comment contained operational context that should be preserved outside the repaired JSON document.

Markdown code fence

Markdown code fence

Strip one outer Markdown fence commonly added around JSON returned by chat assistants, documentation, or copied code blocks.

```json
{"name":"Ada","active":true}
```

Review: Verify that the fence wrapped the entire payload and that no explanatory prose outside the code block was discarded.

Unsupported JavaScript literals

Undefined value · Non-finite number

Replace undefined and non-finite numbers that JavaScript accepts but standard JSON cannot represent with reviewable null placeholders.

{"missing":undefined,"score":NaN,"limit":Infinity}

Review: Decide whether null is the correct business value, or whether the property should be removed or represented another way.

Missing and redundant commas

Missing comma · Redundant comma

Insert a separator between adjacent complete values and remove extra separators only where surrounding tokens identify the boundary.

{"first":1 "second":2,,"third":3}

Review: Confirm that inferred separators match the intended property boundaries and that no omitted value was represented by an empty slot.

Mismatched delimiters

Mismatched delimiter

Replace or add a closing brace or bracket when the nested token stack identifies one bounded structural mismatch.

{"items":[1,2,3}

Review: Inspect the surrounding nesting because heavily damaged objects can have more than one plausible brace or bracket completion.

Escaped JSON string

Escaped JSON string

Decode one outer JSON string layer when a field contains an escaped object or array instead of a directly nested JSON value.

{"payload":"{\"name\":\"Ada\",\"active\":true}"}

Review: Confirm that the field is intended to become a nested object rather than remain a string consumed by another downstream system.

Repair log

Run the repair to see each change and why it was made.

No repair run yet.

JSON encoding troubleshooting

How to recognize JSON that was stringified twice

A double-encoded payload can pass JSON syntax validation because the outer value is a perfectly valid JSON string. After parsing once, however, the result is still text such as {"name":"Ada"} instead of the object your code expected. This tool is free to use. No account or payment is required.

Last updated

What you can do here

  • Browser-local JSON processing
  • Route-specific malformed JSON example
  • Focused parser or repair guidance
  • Broken and corrected JSON example
  • Related JSON problem navigation

Steps

  1. Parse the outer value once and inspect whether the result is a string or an object.
  2. Trace the producer to find where serialized JSON text was passed through JSON.stringify again.
  3. Remove the redundant encoding at the producer when possible; otherwise decode exactly one extra layer at the boundary.

Extra backslashes are a symptom, not the root cause

Backslashes are required when quotation marks from the inner JSON become characters inside the outer JSON string. Blindly deleting them can corrupt legitimate string content.

  • Database column stores JSON text and an API serializes that text as a string.
  • Client stringifies a payload that a request library would already serialize.
  • Message queue envelope contains a serialized JSON body field.

Check the value type after every boundary

The reliable test is whether the first decode returns structured data or another string. Fixing serialization boundaries is safer than repeatedly parsing until something becomes an object.

Double-encoded JSON example

The outer JSON value is a string containing another JSON object. Removing one extra encoding layer yields the intended object text.

Double-encoded JSON

"{\"name\":\"Ada\",\"active\":true}"

Single encoded JSON object

{"name":"Ada","active":true}

Common questions

Frequently asked questions

Is double-encoded JSON invalid JSON?

Not necessarily. The outer document can be valid JSON while representing the wrong type: a string instead of the intended object or array.

Why do I see backslashes before every quote?

Those backslashes escape the inner JSON quotation marks so they can exist inside the outer JSON string.

Should I call JSON.parse twice?

Only when the contract truly contains two serialization layers. Prefer fixing an accidental extra stringify at the producer rather than normalizing it everywhere downstream.

Debugging a specific JSON issue? Browse JSON troubleshooting.