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
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat 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
Paste the string into the input field
Click "Escape for JSON" to make it safe for embedding inside JSON quotes
Click "Unescape from JSON" to convert a JSON-escaped string back to readable text
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.
SELECT *
FROM "users"
WHERE name = "O'Brien"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.
Related Tools
JSON Formatter
Format, validate, and beautify JSON instantly — with clear error messages, Tree View, Diff mode, and Schema validation.
JSON to Base64 Converter
Convert valid JSON into Base64 encoding with syntax validation and copy-ready output.
String Escape / Unescape
Escape or unescape strings for JSON, JavaScript, HTML, URL, CSV, and RegEx contexts — instantly.
HTML Escape / Unescape
Escape and unescape HTML special characters (&, <, >, ", ') on a single page.
XML Escape / Unescape
Escape special XML characters (&, <, >, ", ') to entities and unescape them back. Required for valid XML.
SQL Escape / Unescape
Escape single quotes and special characters in SQL strings. Supports ANSI standard and MySQL dialects.

