JSON Escape Tool
Escape special characters to create valid JSON strings. Paste your text below:
Escape Reference
\"\\\n\t\r\bWhat is JSON Escaping?
JSON strings have strict rules about special characters. Certain characters must be "escaped" with a backslash to be included in a JSON string. This tool automatically converts raw text into a properly escaped JSON string value.
Characters That Need Escaping
The JSON specification requires these characters to be escaped:
| Character | Escaped | Description |
|---|---|---|
" | \" | Double quote — must be escaped inside strings |
\ | \\ | Backslash — the escape character itself |
| Newline | \n | Line feed (LF) |
| Tab | \t | Horizontal tab |
| Carriage return | \r | CR (often paired with \n on Windows) |
| Backspace | \b | Rarely used |
| Form feed | \f | Page break (legacy) |
Example
Raw text:
Hello "World"
Line 2 with tabAfter escaping:
"Hello \"World\"\nLine 2 with\ttab"When to Use This Tool
- Building JSON manually — When concatenating strings into JSON
- Embedding text in JSON — Multi-line content, quotes in values
- API request bodies — Ensuring special characters don't break requests
- Configuration values — File paths with backslashes
- Debug JSON issues — Finding problematic characters
Escaping vs Stringify
This tool escapes a raw string. If you want to convert an entire JavaScript object to a JSON string, use JSON Stringify instead. The difference:
- Escape: raw text → escaped string value
- Stringify: JavaScript object → complete JSON
Options Explained
Wrap in quotes
Enable this to get a complete JSON string value with surrounding quotes. Disable it if you only need the escaped content to insert into an existing JSON structure.
Escape Unicode
When enabled, non-ASCII characters (é, 中, 🎉) are converted to \uXXXX format. This ensures compatibility with systems that don't support UTF-8, though modern JSON parsers handle Unicode natively.
Escaping in Code
In most cases, you should use your language's JSON library instead of manual escaping:
JavaScript
// Don't do this:
const json = '{"name": "' + name + '"}';
// Do this instead:
const json = JSON.stringify({ name: name });
// Or just the string:
const escaped = JSON.stringify(text);Python
import json
# Escape a string
escaped = json.dumps(text)
# Build complete JSON
data = json.dumps({"name": text})Why use libraries?
JSON libraries handle all edge cases correctly — Unicode, control characters, and encoding issues. Manual string building is error-prone and can create security vulnerabilities.
Common Mistakes
Forgetting to escape backslashes
Windows file paths like C:\Users\Name need double backslashes:C:\\Users\\Name
Not escaping quotes
A value containing " breaks the JSON structure unless escaped as \"
Raw newlines in strings
Multi-line strings must use \n — literal newlines are invalid in JSON strings
Related Tools
- JSON Unescape — Reverse: convert escaped strings back to raw text
- JSON Stringify — Convert objects to JSON strings
- JSON Validator — Validate your JSON after building it
- Common JSON Mistakes — Avoid escaping errors
Frequently Asked Questions
What's the difference between escape and stringify?
Escape converts raw text into a valid JSON string value. Stringify converts an entire JavaScript object into a JSON string. Use escape for embedding text; use stringify for converting objects.
Do I need to escape forward slashes?
No. Forward slashes (/) are valid in JSON strings without escaping. Some tools escape them as \/ for HTML compatibility, but it's optional.
How do I escape Unicode characters?
Enable the "Escape Unicode" option to convert characters like é to\u00e9. This is only needed for legacy systems — modern JSON parsers handle UTF-8 natively.