Skip to content

JSON string escaper

Turn any text into a valid JSON string, with quotes, backslashes and line breaks escaped, or unescape a JSON string back into text.

Runs in your browser. Nothing you paste is sent anywhere.

How it works

" → \" ↵ → \n

A JSON string sits between double quotes, so a quote inside it has to be written \", and the backslash itself becomes \\. Line breaks and tabs can’t appear raw: they become \n, \r and \t, and other control characters become \u00XX. Everything else, accents and emoji included, may stay as it is, or be written as \u escapes for ASCII-only output.

  1. Backslash first, then quotes \ → \\ " → \"
  2. Control characters new line → \n · tab → \t · U+0001 → \u0001
  3. Wrap it in double quotes He said "hi" → "He said \"hi\""

JSON escapes

Escape Means
\" double quote
\\ backslash
\/ slash (optional, sometimes used in HTML)
\n new line
\r carriage return
\t tab
\b backspace
\f form feed
\uXXXX any character by its code point

Good to know

  • Unescape accepts the string with or without its outer quotes.
  • The result matches JavaScript’s JSON.stringify() and PHP’s json_encode() with JSON_UNESCAPED_UNICODE.