JSON Escape

Free online JSON Escape/Unescape tool. Escape special characters in JSON strings or convert escape sequences back to literal characters. Works entirely in your browser.

Input
Output
 

How to Use JSON Escape

1

Paste Your JSON String

Paste the JSON string you need to escape or unescape into the input area. This could be a string you want to embed inside another JSON document or code.

2

Choose Direction

Click "Escape" to convert special characters like quotes and newlines into their escape sequences. Click "Unescape" to convert escape sequences back to literal characters.

3

Copy the Result

The processed output appears on the right. Click the Copy button to copy it to your clipboard.

Examples

Before (Unescaped)

He said "Hello World"
Line one
Line two

After (Escaped)

He said \"Hello World\"\nLine one\nLine two

Before (Escaped)

{\"name\":\"John\",\"city\":\"New\nYork\"}

After (Unescaped)

{"name":"John","city":"New
York"}

Frequently Asked Questions

When do I need to escape a JSON string?

You need to escape a string when embedding it as a value inside another JSON document. For example, if you have a JSON string that contains double quotes, you need to escape them so the outer JSON parser doesn't get confused about where the string ends.

What characters get escaped?

The main characters escaped are double quotes (" → \"), backslashes (\ → \\), newlines (→ \n), tabs (→ \t), carriage returns (→ \r), and other control characters. Forward slashes can optionally be escaped but it's rarely needed.

Is this the same as URL encoding?

No. URL encoding (%20, %2F, etc.) is for URLs. JSON escaping uses backslash sequences (\n, \", etc.) and is specifically for embedding strings in JSON format. These are two completely different systems for different purposes.

When JSON Escaping Matters

JSON escaping trips up developers most often when they're building JSON strings by hand — concatenating strings in code instead of using a proper serialization library. If you've ever gotten a SyntaxError: Unexpected token from JSON.parse(), unescaped characters are one of the first things to check.

A common scenario: you're storing a JSON snippet as a string value inside another JSON object. The inner JSON's double quotes need to be escaped so the outer parser treats them as literal characters, not as string delimiters. Without escaping, the parser sees the first inner quote and thinks the outer string ended.

Another case is embedding JSON in HTML <script> tags. If your JSON contains </script> as a string, the browser's HTML parser will close the script tag prematurely. The fix is to escape the / as \/.

Related Articles