JSON escape and unescape

Prepare text for a JSON string, or read text stored inside one. Quotes, backslashes, and line breaks are handled in your browser; your input is not uploaded for conversion.

Choose an operation

Enter any text, including a JSON document. The result includes surrounding double quotes.

Opening a file replaces the input. Its contents stay in this browser.

Empty text is valid: escaping it produces two quotes; unescaping two quotes produces empty text. Examples load only into an empty input.

What changes when you escape text?

Escape adds surrounding double quotes and encodes characters that cannot appear literally inside a JSON string. Unescape reverses that operation. It does not remove every backslash: some backslashes are part of the original text.

Quotes

Original text

She said "hello".

Escaped JSON string

"She said \"hello\"."

Backslashes

Original text

C:\Users\Maya\notes.txt

Escaped JSON string

"C:\\Users\\Maya\\notes.txt"

Newline

Original text

First line
Second line

Escaped JSON string

"First line\nSecond line"

JSON as text

Original text

{"id":9007199254740993}

Escaped JSON string

"{\"id\":9007199254740993}"

When to use it

Use Escape when an API field expects text containing quotes or an entire JSON document. For example, the object {"ok":true} and the JSON string "{\"ok\":true}" have different types. Choose the one the receiving API expects.

Use Unescape for a quoted string copied from a log or response. It decodes one layer, including escapes such as \n and \u0041. If the output is still a quoted JSON string, choose Use result as input, select Unescape, and convert again deliberately.

Escaping treats input as text. It does not parse or reformat a document, so large IDs, spacing, and duplicate keys inside that text are preserved. Unescape rejects objects, arrays, invalid escapes, and missing outer quotes instead of guessing.

This is JSON string encoding, not URL encoding, HTML escaping, or encryption. A decoded string is not necessarily valid JSON. To check its structure, use the JSON validator; to inspect changes, use JSON comparison.