Data & CSV

JSON Escape

JSON Escape

Escape text or JSON so it can sit inside a JSON string, or unescape it back.

About this tool

About JSON Escape

To put text inside a JSON string, some characters must be escaped: double quotes become \", backslashes become \\, and line breaks and tabs become \n and \t. This comes up when you embed a JSON document inside another one (a webhook body, a message queue payload, a config value), paste a Windows path or SQL query into a JSON file, or build a request by hand for curl. Paste any text and the escaped version appears instantly, exactly as JSON.stringify would write it. Options add the surrounding double quotes, escape every non-ASCII character as \uXXXX for systems that only accept ASCII, and escape forward slashes for embedding in HTML script tags. Switch Mode to Unescape to reverse it, with or without the outer quotes; if the result is itself JSON it is pretty-printed for you. Invalid escapes are reported with their position. Everything runs locally in your browser.

Built and maintained by Abhi JainUpdated

How to Escape a JSON String

  1. 1

    Paste text

    Paste the text or JSON you want to embed into the Text pane.

  2. 2

    Choose options

    Tick Wrap in double quotes, Escape non-ASCII as \u or Escape forward slashes if you need them. Switch Mode to Unescape to go the other way.

  3. 3

    Copy the result

    Copy the escaped string, or click Use as input to check it round-trips.

JSON Escape: questions and answers

Which characters must be escaped in JSON?

Inside a JSON string, the double quote (\"), the backslash (\\) and control characters such as line feed (\n), carriage return (\r) and tab (\t) must be escaped. Any character can also be written as \uXXXX.

Do I need to escape forward slashes?

No, \/ is optional in JSON. It is only useful when JSON is placed inside an HTML script element, where a closing script tag in a string would otherwise end the script early.

How do I put JSON inside a JSON string?

Escape the inner JSON here, then paste the result between double quotes as the value. The receiving code parses the string a second time to get the object back.

How do I unescape a JSON string?

Switch Mode to Unescape or use JSON Unescape. Paste the string with or without the surrounding quotes.

Is my text uploaded?

No. Escaping happens in your browser.

Ready-made JSON Escape presets