Skip to content

JSON Escape and Unescape

Escape text for a JSON string, or turn it back.

How to use the JSON escape/unescape

Three steps, all in your browser.

  1. 1

    Paste your input

    Type or paste your code or data. Press Sample to try an example.

  2. 2

    Choose the direction

    Encode or decode. Errors point at what's wrong with the input.

  3. 3

    Copy the result

    Copy the output in one click. Nothing is saved or sent anywhere.

JSON Escape and Unescape: what to know

JSON escape turns any text into a valid JSON string body: double quotes become \", backslashes become \\, and line breaks, tabs and other control characters become \n, \t and \u escapes. Unescape does the opposite, turning a JSON string value back into the original text with real line breaks and quotes.

It's handy whenever you need to put multi-line text, such as a SQL query, an HTML snippet, a certificate or a log message, inside a JSON document by hand, or when you're reading a JSON value full of \n and \" and want to see the text it represents. The rules come from the JSON specification (RFC 8259), so the result works in any JSON parser.

Characters outside ASCII, such as accented letters and emoji, don't need escaping in JSON encoded as UTF-8, so they're left as they are. Escaping the forward slash is optional in JSON, and isn't done here.

Popular uses

  • Putting multi-line text into a JSON config or request body
  • Reading escaped strings in logs and API responses
  • Embedding HTML or SQL inside JSON test fixtures
  • Preparing strings for environment variables that hold JSON

Tips for the best result

  • Escape only the string content; the surrounding quotes are added when you place it in JSON.
  • Seeing \\n instead of \n means the text was escaped twice.
  • Windows line endings come out as \r\n; that's expected.

Read how JustYourDev works and our privacy details. Code, data and files you use here are processed in your browser and are never sent to our server.

Frequently asked questions

The double quote (\"), the backslash (\\) and control characters: newline (\n), carriage return (\r), tab (\t), backspace (\b), form feed (\f), and others as \u followed by four hex digits.

No. JSON allows \/ but doesn't require it. Some encoders escape it so that </script> can't appear inside JSON embedded in an HTML page.

No. Every tool runs in your browser, so your code, tokens, keys and files are processed on your device and are not sent to our server or stored. Reloading or closing the page clears them.

Yes. Every tool is free with no sign-up and no limits on use. Clearly labeled ads keep it that way.

Yes. The tools work in any modern browser on phones, tablets and computers, though large files and long code are easier to handle on a computer.