JSON Escape / Unescape

Escape a plain-text string for use inside JSON, or unescape a JSON string back to readable text.

Ready.

About JSON Escape / Unescape

When embedding text inside a JSON string value, certain characters must be escaped with a backslash to produce valid JSON. This tool handles escaping and unescaping instantly, saving you from manually replacing characters or tracking down subtle JSON parse errors.

JSON Escape Sequences

\" — double quote | \\ — backslash | \n — newline | \r — carriage return | \t — tab | \b — backspace | \f — form feed | \uXXXX — Unicode code point

Common Scenarios

SQL in JSON: Embedding a SQL query string in a JSON config often requires escaping newlines and double quotes. HTML in JSON: Storing HTML snippets in JSON API responses requires escaping angle brackets and quotes. Multi-line strings: JSON doesn't support literal newlines inside strings — they must be represented as \n. Regular expressions: Storing regex patterns as JSON strings requires double-escaping backslashes (\\d+ represents the regex \d+).

Why JSON Parse Errors Happen

Missing escape sequences are one of the most frequent causes of JSON.parse() errors. If your JSON string contains an unescaped double quote, newline, or backslash, the parser throws a SyntaxError: Unexpected token. Use this tool to pre-escape strings before embedding them into JSON templates.

Unescaping Use Cases

When an API returns a JSON string that is itself a JSON object (double-serialized JSON), you first need to unescape the outer string layer before parsing the inner JSON. Logs and monitoring systems often double-serialize JSON, making this tool essential for debugging.