JSON Escape
Escape any text or JSON value so it can be safely embedded as a string literal — wrapping it in double quotes and adding backslash escapes for quotes, newlines, carriage returns, tabs, and other control characters. Switch to stringify mode to serialize an entire JSON object into an escaped single-line string. Output updates live as you type, with no external requests made.
JSON or Plain Text
Mode
Escaped String
What is JSON String Escaper?
Embedding JSON inside another JSON value, storing it in an environment variable, or writing it into an HTML attribute all require the same transformation: every double quote becomes ", every backslash becomes \, and control characters become their escape sequences. Skip this step and the outer structure breaks. Do it manually and you will miss one. This tool applies the complete RFC 8259 escape set to your JSON: double quotes, backslashes, newlines, carriage returns, tabs, backspace, form feed, and all Unicode control characters (U+0000–U+001F). Optionally escape forward slashes (/) for safe embedding inside HTML <script> tags where </script> would otherwise terminate the block. The output can be wrapped in outer double quotes for immediate use as a JSON string literal value, or left unwrapped for storage contexts that do not require the surrounding quotes.
How to Use
- 1
Paste Your JSON to Escape
Paste the JSON object, array, or string value you want to escape. The tool escapes all characters that would break JSON string syntax: double quotes, backslashes, and control characters.
- 2
Set Escape Options
Choose whether to wrap the output in outer double quotes (making it a JSON string literal), escape forward slashes for HTML embedding, and select Unicode escape for non-ASCII characters.
- 3
Escape the Content
Click "Escape". Double quotes become \", backslashes become \\, newlines become \n, tabs become \t, and control characters become \uXXXX sequences.
- 4
Copy the Escaped String
Copy the escaped output for embedding in an environment variable, HTTP header, cookie value, database string column, or as a string field value inside another JSON document.
Common Use Cases
JSON-in-JSON Embedding
Escape a JSON object to embed it as a string value inside another JSON payload — common when storing serialised state, query payloads, or event bodies as string fields in wrapper envelopes.
Environment Variable Encoding
Escape JSON for safe storage in environment variables or .env files where unescaped quotes and backslashes would break the variable value parsing by the shell or runtime.
Database String Column Storage
Escape JSON content before storing in VARCHAR or TEXT database columns that require valid string escaping, preventing syntax errors and injection risks when the value is later read or queried.
HTTP Header Value Encoding
Escape JSON to produce a safe single-line string value for custom HTTP headers, webhook metadata fields, or authentication token payloads that cannot contain raw newlines or unescaped quotes.
Conversion Examples
JSON Object → Escaped JSON String
Quotes and special characters are backslash-escaped for safe embedding as a string.
Input JSON
{
"name": "Alice",
"message": "Hello, World!",
"active": true
}Output CSV
{"name":"Alice","message":"Hello, World!","active":true}JSON with Special Characters → Escaped
Backslashes, newlines, and tab characters are double-escaped for string safety.
Input JSON
{
"path": "C:\Users\alice",
"note": "Line 1
Line 2",
"tab": "col1 col2"
}Output CSV
{"path":"C:\\Users\\alice","note":"Line 1\nLine 2","tab":"col1\tcol2"}