Online JSON Unescape & String Cleaner
Unescape double backslashes, escaped quotes (\"), and clean stringified payloads instantly.
Developers dealing with database logs, API webhooks, or cURL output frequently encounter double-escaped JSON string literals like "{\"user\": \"\\\"John\\\"\", \"id\": 101}". Passing such strings into standard JSON.parse() methods leads to immediate syntax errors like Uncaught SyntaxError: Unexpected token in JSON at position or JSON.parse error bad control character in string literal.
1. Understanding escape sequences in JSON
In standard JSON syntax, string values containing double quotes or control characters must be escaped with a backslash (\", \n, \t, \\). When an already-stringified JSON object is serialized a second time (for instance, storing a JSON payload inside a text column in PostgreSQL or logging via Datadog), backslashes are themselves escaped, producing double backslashes (\\\" and \\\\).
2. Common causes of double-escaped JSON
- Nested REST API Payload Serializations: Calling
JSON.stringify()on an object that already contains a stringified property value. - Database SQL String Exports: Exporting string columns containing JSON text without unescaping double quotes.
- Log Aggregators & Shell CLI Logs: cURL parameters or Bash echo outputs escaping quotes for terminal compatibility.
3. Programmatic fixes in popular languages
JavaScript / Node.js
In JavaScript, double-escaped strings require double parsing or string replacement:
// Double parse pattern for double-encoded JSON
const rawString = "\"{\\\"user\\\": \\\"John\\\", \\\"role\\\": \\\"admin\\\"}\"";
const firstPass = JSON.parse(rawString); // Returns string payload
const validObject = JSON.parse(firstPass); // Returns JavaScript object
console.log(validObject.user); // "John"
Python
In Python, use the json.loads() function twice or codecs.decode():
import json
escaped_str = '"{\\"user\\": \\"John\\", \\"role\\": \\"admin\\"}"'
# Parse outer string then inner object
clean_str = json.loads(escaped_str)
data = json.loads(clean_str)
print(data['user']) # 'John'
Go (Golang)
In Go, unquote the string before unmarshaling into a struct:
package main
import (
"encoding/json"
"fmt"
"strconv"
)
func main() {
escaped := `"{\"user\": \"John\", \"role\": \"admin\"}"`
unquoted, _ := strconv.Unquote(escaped)
var result map[string]interface{}
json.Unmarshal([]byte(unquoted), &result)
fmt.Println(result["user"]) // John
}
4. Instant in-browser unescaping
Instead of writing fragile regex replace expressions or manual terminal commands, paste your double-encoded payload into OnlineViewer Dev's JSON Unescape Tool. It detects escaped quote patterns (\" → "), unescapes double backslashes, and instantly produces cleanly formatted JSON trees.
5. Frequently asked questions
How do I fix 'Uncaught SyntaxError: Unexpected token in JSON at position'?
This error occurs when passing a string containing unescaped quote characters or double-encoded escape backslashes to `JSON.parse()`. Unescaping the string beforehand resolves the token mismatch.
How do I unescape escaped Unicode sequences like \u0026 in JSON?
Unicode escape sequences (e.g. `\u0026` for `&`) can be converted using standard `JSON.parse()` or Web API decoding functions integrated into OnlineViewer Dev string utilities.
Fix double escaped JSON right now
Paste your escaped API log or cURL string to remove backslashes and format into clean JSON in 1 click.
Launch JSON Unescape Utility