Skip to content

JSON String Escape & Unescape

Turn raw text into a valid JSON string literal, or decode a quoted JSON string without confusing it with HTML escaping.

Local Browser Processing Free Forever No Signup Mobile Friendly

Processing stays in this browser. Inputs are not sent to a tool-processing server or saved by this utility. Limit: 500,000 characters per input.

How to use JSON String Escape & Unescape

  1. Select Escape to encode raw text as a complete JSON string literal.
  2. Select Unescape to decode a JSON string that includes its surrounding double quotes.
  3. Copy the result and verify the receiving format; JSON escaping is not HTML sanitization.

A reproducible example

Use Load example to try this input, then change one value and inspect the result.

Hello "Ada"
Path: C:\projects\api

Keep the surrounding quotes

JSON.stringify produces a complete string literal, including its surrounding double quotes. Newlines become \n, literal quotes become \" and backslashes are escaped. Use the complete literal as a JSON value. Manually removing quotes can turn a valid string into an invalid document.

Decode one string layer at a time

An API can return a string that itself contains serialized JSON. Unescape decodes one JSON string layer and requires the result to be a string. A JSON object or number is rejected. If the decoded text is another JSON document, validate that document separately rather than repeatedly unescaping until something looks readable.

Avoid double escaping

If your HTTP library already serializes an object, supply raw string values to it. Escaping those values first can cause literal backslashes to appear in the recipient’s data. Compare the raw value, serialized request body and parsed value at the receiver to locate the extra encoding layer.

Do not confuse formats

A JSON string can contain markup. Escaping it as JSON does not make it safe to insert through innerHTML or into an inline script. Use textContent for plain-text display and context-appropriate encoding for HTML, attributes or scripts. This tool preserves text; it does not sanitize it.

Common questions

Is this the same as URL encoding?

No. JSON strings and URL components have different encoding rules.

Can I unescape an object?

No. Use a JSON formatter for objects. This utility specifically decodes string literals.

Read the format or engine documentation. Found an edge case? Send a small reproducible example.