JSONHack
Validator · Formatter · Base64
String Tool

JSON Escape / Unescape

📅Last updated:

Escape special characters in a plain text string so it can be safely embedded inside a JSON value. Or unescape a JSON-encoded string back to its original readable form. All processing happens locally in your browser.

Input
Paste plain text to escape, or a JSON-escaped string to unescape
Output

JSON Escape Characters Reference

CharacterEscapedDescription
"\"Double quote — must be escaped inside JSON strings
\\\Backslash — must be escaped to avoid ambiguity
newline\nLine feed / new line character
tab\tHorizontal tab character
carriage return\rCarriage return character
/\/Forward slash (optional but valid)
backspace\bBackspace character
form feed\fForm feed character

When Do You Need to Escape JSON?

Escape vs Encode — What's the Difference?

JSON escaping adds backslash sequences for special characters within a string value. It is different from URL encoding (which uses % sequences) and Base64 encoding (which converts binary to ASCII). Use JSON escaping when you need to embed a string safely inside a JSON document. Use URL encoding for query parameters, and Base64 for binary data.

Need to validate the full JSON?

Use the JSON validator to check the complete document.

Open JSON Validator →

JSON Escape vs Other Encoding Methods

Developers often confuse JSON escaping with other encoding techniques. Understanding the difference helps you choose the right tool for each situation.

Complete JSON Escape Sequences Reference

The JSON specification (RFC 8259) defines the following escape sequences that must or can be used inside JSON string values:

Practical Examples of JSON Escaping

Here are real-world scenarios where JSON escaping is required:

// Storing a Windows file path (backslashes must be escaped)
{"path": "C:\\Users\\Alice\\Documents"}

// Storing HTML content inside a JSON string
{"html": "

Hello World

"} // Multi-line text stored as a JSON string {"message": "Line 1\nLine 2\nLine 3"} // JSON containing a serialized JSON string (double-escaped) {"data": "{\"name\":\"Alice\",\"age\":28}"}

How to Avoid JSON Escape Errors

Why JSON Escaping Matters for Security

Improper JSON escaping can lead to serious security vulnerabilities. If user-supplied text is embedded into a JSON string without proper escaping, an attacker could inject additional JSON keys or break out of the string context entirely — a form of JSON injection. Always escape user input before embedding it in JSON, and use established serialization libraries rather than building JSON strings manually.

Related Tools