WebToolsPlanet
Developer Tools

JSON Escape / Unescape

Escape a string so it is safe to embed inside a JSON string value, or unescape a JSON-encoded string back to its original readable form.

Last updated: May 28, 2026

Client-Side Processing
Input Data Stays on Device
Instant Local Execution

Find this tool useful? Support the project to keep it free!

Buy me a coffee

What is JSON Escape / Unescape?

JSON string values have their own escaping rules. The following characters must be escaped with a backslash: double quote (\"), backslash (\\), and control characters including newline (\n), carriage return (\r), and tab (\t). Unescaped newlines and quotes inside a JSON string cause parse errors.

This tool escapes raw text into JSON-safe form, or reverses the process to recover the original string from a JSON-escaped value. Useful when manually constructing JSON, debugging serialisation output, or embedding multi-line strings in JSON configuration files.

How to Use JSON Escape / Unescape

1

Paste the string into the input field

2

Click "Escape for JSON" to make it safe for embedding inside JSON quotes

3

Click "Unescape from JSON" to convert a JSON-escaped string back to readable text

4

Copy the output for use in your JSON payload or config file

Common Use Cases

  • Developers embedding multi-line SQL queries or code snippets as JSON string values in configuration files.
  • API engineers manually constructing JSON request bodies where field values contain double quotes or backslashes.
  • Support engineers copying error messages containing special characters into JSON-formatted log entries.
  • QA testers verifying that a JSON serialiser correctly escapes all required characters in string values.
  • Frontend developers embedding user-generated content inside JSON data attributes or inline script JSON blocks.

Example Input and Output

Escaping a multi-line SQL query so it can be embedded as a single JSON string value without breaking the JSON structure.

Raw string
SELECT *
FROM "users"
WHERE name = "O'Brien"
JSON-escaped output
SELECT *\nFROM \"users\"\nWHERE name = \"O'Brien\"

Wrap in quotes yourself

This tool escapes the content only. When embedding the result in JSON, remember to wrap it in double quotes: "your-escaped-value".

Browser-side only

All processing runs locally in your browser. No content is transmitted.

Frequently Asked Questions

Which characters are escaped for JSON?
Double quote (\ ") → \\", backslash → \\\\, newline → \\n, carriage return → \\r, tab → \\t. Other Unicode control characters also require escaping in strict JSON.
Is this the same as JSON.stringify()?
Similar, but JSON.stringify() also adds the surrounding double quotes and serialises the whole value. This tool escapes only the content, leaving you in control of how it is embedded.
What is the difference between JSON escaping and Base64?
JSON escaping makes a string safe inside a JSON string value using backslash sequences. Base64 encodes bytes to a 64-character alphabet. They serve different purposes and are not interchangeable.
Does this tool validate JSON?
No — this tool operates on plain string values, not full JSON documents. To validate or format a complete JSON document, use the JSON Formatter tool.
Is my content sent to a server?
No. All escaping runs in your browser.