JSON String Escaping: Quotes, New Lines and Backslashes
Learn why JSON strings need escaping and how to avoid double-escaping copied values.
JSON Escape / Unescape helps you apply this guide directly in the browser.
Why JSON strings are escaped
A JSON string is surrounded by double quotation marks. Any quotation mark that belongs to the value must therefore be escaped so it is not mistaken for the end of the string.
Line breaks, tabs and backslashes also use escape sequences. For example, a line break is represented as backslash-n inside the serialized JSON text.
Watch for double-escaping
Double-escaping happens when an already escaped value is escaped again. Backslashes multiply and the receiving application may display the escape characters instead of the intended text.
Check whether your source is raw text, a JSON string or a full JSON document before converting it.