JSON Escape & Unescape

Escape & unescape
JSON strings online

Handle special characters, newlines, quotes, and Unicode in JSON strings. Paste your text and get properly escaped output instantly. Free, private, runs in your browser.

Open JSON Escape Tool
🔤

Escape Special Characters

Properly escape quotes, backslashes, newlines, tabs, and Unicode characters for valid JSON strings.

🔓

Unescape Strings

Convert escape sequences back to readable characters. See \\n become actual newlines and \\t become tabs.

Instant Processing

Results appear as you type. No submit button, no server call, no waiting.

Everything for JSON string encoding

Quote Escaping Properly escape double quotes inside JSON strings so they do not break your JSON structure.
Newline & Tab Handling Convert literal newlines to \\n and tabs to \\t, or unescape them back to readable whitespace.
Unicode Support Encode non-ASCII characters as \\uXXXX sequences for maximum compatibility across systems.
Backslash Handling Correctly escape backslashes — the most common source of JSON string errors in file paths and regexes.
Validation Included The formatter validates your JSON in real time, catching escape-related errors with precise locations.
Copy & Download One-click copy to clipboard or download the properly escaped JSON as a .json file.

No account. No upload. No nonsense.

🔒

100% Private

Your data never leaves your device. There is no server receiving your strings.

🎯

RFC 8259 Compliant

Escaping follows the official JSON standard — compatible with every JSON parser.

🌐

Works Offline

Install as a PWA and escape JSON strings without an internet connection.

Related JSON tools

JSON Validator Validate JSON syntax with precise line and column error locations.
JSON Repair Automatically fix broken JSON — single quotes, unquoted keys, trailing commas.
Base64 JSON Encode and decode JSON to and from Base64 for safe transport.
JSON Formatter Pretty-print JSON with syntax highlighting and a collapsible tree view.
JSON Pretty Print Beautify minified JSON with clean indentation and syntax highlighting.
JSON Minifier Strip all whitespace and compress JSON to the smallest valid form.

Common questions answered

What characters need to be escaped in JSON?

JSON requires escaping double quotes (\"), backslashes (\\), and control characters including newline (\n), carriage return (\r), tab (\t), backspace (\b), and form feed (\f). Unicode characters outside the basic ASCII range can optionally be escaped as \uXXXX sequences.

What is the difference between JSON escape and stringify?

JSON.stringify() converts a JavaScript value to a JSON string, wrapping it in quotes and escaping special characters. JSON escaping specifically refers to converting special characters within a string to their escape sequences so the string is valid inside JSON.

Is the JSON escape tool free?

Yes, completely free with no account or signup required. All escape and unescape operations are available immediately.

Is my data sent to a server?

No. All escaping and unescaping runs entirely in your browser using JavaScript. Your data is never uploaded or transmitted to any server.

How do I unescape a JSON string?

Paste your escaped JSON string into the formatter and it will automatically parse and display the unescaped content. Escape sequences like \n become actual newlines, \t becomes tabs, and \" becomes regular quotes.

What is JSON string escaping?

JSON string escaping converts special characters into backslash-prefixed equivalents so they can be safely embedded inside a JSON string value. The JSON specification requires escaping double quotes (\"), backslashes (\\), and control characters like newline (\n), tab (\t), and carriage return (\r). Without proper escaping, these characters break JSON structure.

Escaping is critical when embedding one JSON document inside another as a string value — a common pattern in logging, message queues, and API request bodies. This tool takes any text input and produces a properly escaped JSON string. It handles Unicode escaping (\uXXXX) for non-ASCII characters when needed.

Escape a string for JSON embedding
Input
He said "hello"
New line here	and a tab
Output
"He said \"hello\"\nNew line here\tand a tab"

Get the most out of this tool

Ready to escape your JSON strings?

Free forever. No signup. Instant results. Works offline.

Open JSON Escape Tool

JSON string escaping explained

JSON string escaping is the process of converting special characters within a string value into their escape sequence equivalents, making the string safe to embed in a JSON document. The JSON specification requires that all characters with special meaning — double quotes, backslashes, and control characters — be escaped with a preceding backslash. Without proper escaping, these characters would break the JSON syntax or be interpreted differently than intended.

The mandatory escape sequences in JSON are: \" (double quote), \\ (backslash), \/ (forward slash — optional but allowed), \b (backspace, U+0008), \f (form feed, U+000C), \n (newline, U+000A), \r (carriage return, U+000D), and \t (horizontal tab, U+0009). Any other Unicode code point below U+0020 (the control characters) must be escaped as \uXXXX where XXXX is the four-digit hexadecimal code point. Characters above U+007E can optionally be escaped or left as literal Unicode.

The most common escaping scenario is embedding a JSON string inside another JSON string — "JSON-in-JSON" or stringified JSON. When a JSON value is itself a JSON document (for example, when storing a JSON config blob as a string value in a larger JSON config), all the double quotes, backslashes, and newlines in the inner JSON must be escaped. This produces an unreadable but technically valid outer JSON string. This tool handles this conversion automatically.

Embedding JSON in other languages requires different escaping conventions. In Java and C# string literals, backslash must be escaped as \\\\ (four backslashes: two for the JSON, two for the language string). In Python raw strings (r"..."), backslash is literal but the string cannot contain a backslash followed by quotes. In shell scripts, embedding JSON requires careful quoting to prevent the shell from interpreting backslashes and dollar signs. This tool can produce language-specific escaped output for these contexts.

The unescaping operation is the reverse: converting escape sequences back to their literal character equivalents. This is needed when you receive a JSON string value that contains escaped content you want to read as plain text. For example, a database storing JSON might return a string like "First line\\nSecond line" — unescaping converts \\n back to an actual newline character. This tool handles both escaping and unescaping in either direction.

Unicode escaping (\uXXXX) is relevant for internationalization and for ensuring JSON is safe for ASCII-only channels. While UTF-8 JSON is allowed to include literal Unicode characters, some protocols and legacy systems only support ASCII. Using \uXXXX escapes for all non-ASCII characters produces JSON that is safe in any context. The tradeoff is larger file size and less human-readable content. For modern systems with full UTF-8 support, literal Unicode is preferred.

When developers use this tool

Embedding JSON in JSON When storing a JSON configuration blob as a string field in another JSON document (common in database schemas and API payloads), escape the inner JSON to make it a valid string value in the outer document.
Preparing strings for code embedding When embedding a JSON string literal in Java, C#, or Python code, convert the JSON to the correctly escaped string literal for that language, accounting for each language's own string escape conventions.
Fixing broken escaped JSON Double-escaped JSON (where escapes were applied twice) is a common bug. Unescape the string once to see if you get valid JSON, which reveals where an extra escape step was incorrectly added in the processing pipeline.
Shell script JSON generation Generating JSON in shell scripts requires careful escaping of values that might contain quotes, newlines, or backslashes. Use this tool to pre-escape problematic values before incorporating them into shell-generated JSON.

Additional frequently asked questions

Why do I need to escape JSON strings at all?

JSON uses double quotes to delimit string values. If a string value contains a double quote, the parser would think the string ends there and fail to parse the remaining content. Escaping converts the quote to \" so the parser treats it as content, not a delimiter. Without escaping, any string containing a quote, backslash, or control character would produce invalid JSON.

What is the difference between JSON escaping and HTML escaping?

JSON escaping converts special characters for safe embedding in JSON strings (using backslash sequences). HTML escaping converts characters for safe embedding in HTML (using &, <, >, " entities). Both are needed when embedding JSON in HTML — JSON-escape the string values, then HTML-escape the entire JSON for safe embedding in HTML attributes or inline scripts.

Is \/ (forward slash) always required in JSON strings?

No. Forward slashes in JSON strings do not need to be escaped — they are allowed as literal characters. Escaping them as \/ is optional and produces valid JSON. Some JSON serializers escape forward slashes by default (notably older PHP versions) to prevent </script> sequences from breaking HTML, but modern serializers leave them unescaped.

What happens if I double-escape a JSON string?

Double escaping is a common bug where a string is escaped twice. A backslash becomes \\\\ (four characters representing two backslashes, instead of the intended one). A quote becomes \\\\" (four characters). The resulting string is syntactically valid JSON but semantically wrong — it contains the literal escape sequences instead of the actual characters. Unescape once to recover the correctly single-escaped form.