JSON escape and unescape
Escape turns any text into a JSON string you can paste into a JSON document. Unescape does the reverse, taking a string like "Line one\nLine two" from a log or API response and giving you the plain text. Everything runs in your browser.
Paste any text, even a whole JSON document. The result comes back wrapped in double quotes.
Opening a file replaces whatever is in the box. The file isn’t uploaded.
Escaping empty text gives you two quote marks, and unescaping two quote marks gives you empty text. To load an example, clear the input first.
What escaping does
A JSON string has to be wrapped in double quotes, and a few characters can’t appear in it as they are. Escaping adds the quotes and puts a backslash in front of any double quotes and backslashes inside. Line breaks and tabs become \n and \t. It’s the same thing JSON.stringify does to a string in JavaScript.
Quotes
Original text
She said "hello".Escaped JSON string
"She said \"hello\"."Backslashes
Original text
C:\Users\Maya\notes.txtEscaped JSON string
"C:\\Users\\Maya\\notes.txt"Newline
Original text
First line
Second lineEscaped JSON string
"First line\nSecond line"JSON inside a string
Original text
{"user":"maya","active":true}Escaped JSON string
"{\"user\":\"maya\",\"active\":true}"When you need it
The most common case is an API field that takes text, where the text has quotes or line breaks in it. Another is a field that expects a whole JSON document as a string, which some APIs and message queues do. The object {"ok":true} and the string "{\"ok\":true}" aren’t the same thing, so check which one the API wants.
Unescape is for the opposite situation: you’ve copied a quoted string out of a log or a response and want to read it. Paste it with its outer quotes. It decodes one layer at a time, so if what you get back is still a quoted string, it was escaped twice. Choose Use result as input and unescape it again.
Escape doesn’t parse or reformat what you give it, so whatever you paste comes back exactly, just escaped. Unescape needs a single valid JSON string. It won’t accept an object, an array, or text without the outer quotes, because guessing would risk changing your text.
This is only for JSON strings. URLs and HTML have their own escaping rules, and escaping isn’t a way to hide anything. If the unescaped text is meant to be JSON, check it in the JSON validator.
Doing it in code
// JavaScript
JSON.stringify(text) // escape
JSON.parse(jsonString) // unescape
# Python
json.dumps(text) # escape
json.loads(json_string) # unescape