input
output

    

How to escape a JSON string

Paste your text into the input box and press Escape. Characters that are not allowed inside a JSON string are replaced with escape sequences: a double quote becomes \", a backslash becomes \\, a new line becomes \n, and a tab becomes \t. This is what you need when you want to put JSON, code or multi-line text inside another JSON value.

Example: escaping JSON text

Input:

{"name": "Ali"}

Escaped result:

"{\"name\": \"Ali\"}"

How to unescape a JSON string

Paste an escaped string, with or without the surrounding quotes, and press Unescape. Sequences such as \", \n and \u00e9 are converted back to the real characters. If the result is itself valid JSON, the tool tells you, so you can copy it into the JSON Formatter to read it easily.

Frequently asked questions

Which characters are escaped in a JSON string?

Double quotes, backslashes, and control characters such as new lines, tabs and carriage returns. Optionally, all non-ASCII characters can be written as \uXXXX sequences.

Should I keep the surrounding quotes?

Keep them if you are pasting the result as a complete JSON string value. Turn the option off if you only want the escaped inside, for example to place it between quotes you already have.

Why do I get an error when unescaping?

Usually the text contains a double quote that is not escaped, or a backslash that is not followed by a valid escape character. Fix those characters and try again.

Is my text uploaded to a server?

No. Everything runs in your browser with JavaScript, so it is safe to use with private data.

Is this tool free?

Yes. It is free, needs no signup, and has no usage limits.

Related tools

Check the result with the JSON Formatter. Compare two versions with JSON Diff. Encode text with Base64 or URL Encode.

Ad placement — in-content (below tool, above footer)