Escape text for use inside JSON
Before you can drop arbitrary text into a JSON string, characters like double quotes, backslashes, and line breaks have to be escaped or the JSON breaks. This tool does that for you: paste raw text and get a properly escaped version you can wrap in quotes and use as a JSON value. Switch to Unescape to turn an escaped string back into the original text.
What gets escaped
- Double quotes become
\"so they do not end the string early. - Backslashes become
\\. - Newlines, tabs, and carriage returns become
\n,\t, and\r. - Other control characters become their
\uescape codes.
Frequently asked questions
How do I escape a string for JSON?
Paste your raw text with Escape selected. The tool returns the escaped version, ready to paste between quotes as a JSON value.
How do I unescape a JSON string?
Select Unescape and paste the escaped string. The tool decodes the escape sequences back into the original text.
Do I need to add the surrounding quotes?
The escaped output is the inside of the string, without the outer quotes, so you can place it anywhere a JSON string value goes.
Is my input private?
Yes. Escaping and unescaping run entirely in your browser.