JSON Escape / Unescape
Paste text to escape it into a valid JSON string literal, or paste an escaped string to decode it — instantly, in your browser.
Updated
How to use JSON Escape / Unescape
The JSON Escape / Unescape tool converts text into a safe JSON string literal — or decodes an escaped string back to plain text — instantly in your browser. Escaping turns quotes, backslashes, newlines, tabs and other control characters into their backslash sequences so the result can be embedded inside a JSON document without breaking it. Unescaping reverses the process, turning \n, \t and \uXXXX sequences back into real characters. Everything runs locally with JavaScript, so even sensitive payloads never leave your device.
- Select the "Escape" tab to convert plain text into a JSON string, or "Unescape" to reverse it.
- Paste your text into the input area.
- For escaping, optionally enable "wrap in quotes" to produce a complete literal.
- Read the converted result in the output panel as you type.
- Click copy to grab the escaped or unescaped result for use in your code.
Your data never leaves your device — 100% private processing.
Which characters must be escaped in JSON?
The JSON specification (RFC 8259) requires that double quotes and backslashes always be escaped inside a string, along with the so-called control characters in the range U+0000 to U+001F. Common ones have short forms — \n for newline, \r for carriage return, \t for tab, \b for backspace and \f for form feed — while any remaining control character must use the six-character \uXXXX form. Forward slashes may optionally be escaped as \/ but this is never required. Getting these rules right by hand is error-prone, which is exactly why a dedicated escaper is useful when you are authoring JSON manually.
| Character | Escape | Notes |
|---|---|---|
| Double quote | \" | Always required inside a string |
| Backslash | \\ | Always required |
| Newline | \n | Control character shorthand |
| Tab | \t | Control character shorthand |
| Other control chars | \uXXXX | Six-character Unicode form |
Escaping versus encoding
JSON escaping is not the same as URL encoding or HTML entity encoding, even though all three make text safe for a particular context. JSON escaping only deals with the handful of characters that would otherwise terminate or corrupt a JSON string — primarily quotes, backslashes and control characters. It does not touch letters, digits, spaces or most punctuation, which remain perfectly valid inside a JSON string. If you need to put a value into a URL you want URL encoding, and if you are inserting into HTML you want entity encoding. Reach for JSON escaping specifically when you are assembling a JSON document by hand or generating one in a templating context that lacks a proper serializer.
Worked examples
Escape a multi-line string
Inputs: line one line "two"
Result: line one\nline \"two\"
Unescape a JSON string
Inputs: tab\there
Result: tab here
Glossary
- String literal
- A run of characters surrounded by double quotes that represents a text value inside a JSON document.
- Escape sequence
- A backslash followed by one or more characters that represents a character which cannot appear literally, such as \n for a newline.
- Control character
- A non-printing character in the U+0000–U+001F range that must be escaped in JSON.
- Unescape
- The reverse operation that converts escape sequences back into the characters they represent.
- RFC 8259
- The IETF standard that defines the JSON data interchange format, including string-escaping rules.
Related reading
Frequently Asked Questions
Get weekly tool tips & updates
New tools, power-user tips, and productivity hacks — delivered free every Friday.
No spam, ever. Unsubscribe with one click.
Why use JSON Escape / Unescape?
- Turn arbitrary text into a valid JSON string literal you can paste straight into a JSON file
- Optionally wrap the output in double quotes to get a complete, ready-to-use literal
- Unescape JSON strings to recover the original multi-line text for reading and editing
- Correctly handles control characters such as newline, tab, carriage return and form feed
- Processes everything in your browser — no payload is ever uploaded
Common use cases
- Embed a multi-line code snippet or log message inside a JSON config file
- Build a JSON request body by hand in a REST client or documentation example
- Decode an escaped JSON string copied from an API response to read it comfortably
- Prepare text containing quotes and backslashes for a JSON-based test fixture
- Inspect \uXXXX escape sequences by converting them back to readable characters
Related Developer Tools
JSON Formatter & Validator
Format, validate, and minify JSON instantly. Includes syntax highlighting, error detection, and a collapsible tree view — free, private, in-browser.
String Escape / Unescape
Escape or unescape strings for JavaScript, Java, C/C++, JSON, SQL, CSV and shell. Safely embed quotes and special characters, processed in your browser.
URL Encoder / Decoder
Encode and decode URLs and URL components online. Convert special characters to percent-encoding and back instantly — free, private, and fast.
Regex Tester
Test and debug regular expressions online. See live matches, capture groups, and replace output. Free, private, instant.
Base64 Encoder & Decoder
Encode text or files to Base64, or decode Base64 strings back to text. Fast, free, and runs entirely in your browser.
HTML Encoder / Decoder
Encode and decode HTML entities online. Escape <, >, &, and quote characters for safe HTML display. Free, instant, and private — runs in your browser.
Explore all Developer Tools.