datapry

JSON Escape / Unescape

Turn text into a safe JSON string, or decode an escaped string back to text. Runs in your browser, so nothing is uploaded.

Mode

Text

Result

Waiting for input

About this tool

Embedding text in JSON means escaping quotes, backslashes and line breaks correctly. Escape turns any text into a valid JSON string, ready to paste into a payload. Unescape does the reverse, which helps when reading strings nested inside logs or API responses.

How to use it

  1. Choose Escape or Unescape.
  2. Paste your text.
  3. Copy the result, with or without surrounding quotes.

Example

Input
He said "hi"
C:\temp
Output
"He said \"hi\"\nC:\\temp"

Questions

Which characters get escaped?
Double quotes, backslashes and control characters such as newlines and tabs. Other Unicode characters are valid in JSON strings and stay as they are.
Does unescape need the surrounding quotes?
No. It accepts both "line\nbreak" and line\nbreak. Unescaped double quotes inside the text are reported as an error.
Can I unescape a string that holds JSON?
Yes. Unescaping gives you the inner JSON as text, which you can then paste into the JSON Formatter.