JSON Escape / Unescape

Escape text into a valid JSON string value or unescape it back.

0 chars
0 words
0 lines
0 chars
0 words
0 lines

JSON Escape and Unescape Online

This JSON escape tool converts any text into a valid JSON string value, and the Unescape mode turns an escaped JSON string back into readable text. It is useful whenever you have to paste a multi-line message, a Windows path, an HTML template, or a log line into a JSON config file, an API request body, or a test fixture by hand.

JSON string rules

The JSON specification (RFC 8259) is strict and small. Inside a string:

  • " must be written as "
  • ` must be written as \`
  • control characters must be escaped: \n (line feed), \r, \t, \b, \f, or \u0000–\u001F
  • / may be written as /, but doesn't have to be

A path like C:\Users\admin therefore becomes C:\Users\admin, and a two-line message becomes a single line with \n in the middle. Unlike JavaScript, JSON has no ', \x41, or \u{1F600} escapes, and characters above U+FFFF are written as a surrogate pair such as \ud83d\ude00.

Options

  • Escape non-ASCII as \uXXXX – produce pure ASCII output, e.g. café → caf\u00e9. Handy for systems that mangle UTF-8 or for byte-exact comparisons.
  • Wrap in quotes – add the surrounding double quotes so the result can be pasted straight after "key": .

Common bugs this fixes

"Unexpected token" and "Bad control character in string literal" errors usually come from an unescaped quote or a raw line break inside a value. Building JSON by string concatenation is the typical cause – prefer JSON.stringify() or your language's serializer in code, and use this page for quick manual edits and debugging escaped payloads found in logs.

Related tools: JavaScript Escape / Unescape for JS string literals and JSON to Base64 for transporting JSON in headers or URLs.

Frequently Asked Questions

Only three groups: the double quote (\"), the backslash (\\), and control characters U+0000 to U+001F such as newline (\n), tab (\t), and carriage return (\r). Everything else, including emoji and accented letters, may appear literally in UTF-8 JSON.

No. JSON strings must be enclosed in double quotes, and \' is not a valid escape sequence. A single quote inside a JSON string needs no escaping at all. If your data uses single-quoted strings it is a JavaScript object literal, not JSON – use the JavaScript Escape tool instead.

The line separator and paragraph separator characters are valid inside JSON but were illegal in JavaScript string literals before ES2019. Escaping them as \u2028 and \u2029 keeps the JSON safe when it is embedded in a <script> block or evaluated as JavaScript by older engines.

Paste it as is. The unescaper accepts both a bare escaped value (Hello\nWorld) and a complete JSON string literal ("Hello\nWorld"). Raw line breaks in the input are tolerated, but an unescaped double quote in the middle is reported as an error.