About JSON string escaping
Inside a JSON string, a double quote would end the string, a backslash starts an escape, and a real line break is not allowed at all. Escaping writes them as \", \\, and \n (and tabs and other control characters as \t or \uXXXX), so any text can be dropped into a JSON value, an API request body, or a configuration file without breaking it. Unescaping reverses the process, which is handy when a log or an API returns text full of backslashes. You can also escape every non-ASCII character for systems that only accept ASCII JSON.
How to escape or unescape a JSON string
- Paste your text. Paste plain text to escape, or an escaped JSON string to unescape, or press an example. An example only fills the box.
- Choose Escape or Unescape. For escaping, choose whether to write non-ASCII characters as \uXXXX and whether to add surrounding quotes.
- Press Convert. The result appears below; copy it into your JSON or code.
Frequently asked questions
Which characters are escaped?
Double quotes become \", backslashes become \\, line breaks become \n, carriage returns \r, tabs \t, and other control characters \uXXXX. Single quotes and forward slashes do not need escaping in JSON and are left alone.
Can I paste the value with its surrounding quotes?
Yes. When unescaping, quotes at the very start and end of the text are removed first, so both "C:\\temp" and C:\\temp work.
When should I escape non-ASCII characters?
Only when the receiving system cannot handle UTF-8. With the option on, é becomes \u00e9, and an emoji becomes a pair of \u codes (a surrogate pair), which every JSON parser reads back correctly.
Is this the same as JSON.stringify?
Escaping produces the same content as JSON.stringify of a string, without the surrounding quotes unless you ask for them.