JSON Escape / Unescape
Escape or unescape JSON string characters.
Loading…
About JSON Escape / Unescape
Pasting a multi-line message or a Windows path straight into a JSON string breaks the document, because quotes, backslashes and line breaks all need escapes. Drop the raw text in and the output is ready to sit between your own double quotes: a backslash is doubled, a newline becomes \n, a tab becomes \t and other control codes become \u00XX sequences. Accented letters, emoji and the forward slash stay as they are. Unescape reverses it and tells you where an invalid escape sits.
Features
- Escapes quotes, backslashes and control characters
- Newlines and tabs become \n and \t, other control codes become \u00XX
- No outer quotes added, so you place it inside your own
- Unescape accepts text with or without surrounding quotes
- Names the invalid escape and its position when unescaping fails
Limitations
- Unescape rejects escapes that JSON does not define, such as \q, \' or a \u not followed by four hex digits.
- Forward slashes and non-ASCII characters are left as they are, and there is no option to write them as \/ or \uXXXX.
How it works
- Paste the raw text, or the escaped string, into the JSON Input panel.
- Choose Escape or Unescape with the toggle in the middle column.
- Read the JSON Output panel, which updates as you type, and look for an error box if Unescape fails.
- Select Copy Output and paste it between double quotes in your JSON, or Clear All to start over.
Example input
Line one
Line two with a "quote" and a \ backslashFrequently asked questions
- Yes. The output is only the inside of a JSON string, so put double quotes around it. To turn a whole JSON document into one quoted string in a single step, use the JSON Stringify tool.
- Each backslash is doubled, so C:\Users\me becomes C:\\Users\\me. JSON then reads the doubled pair as one backslash again, which is why raw paths pasted into a string field break the document.
- That escape is valid in JavaScript but not in JSON, which allows only a short fixed list. The error names the sequence and its position. Remove the backslash, or run the text through JavaScript Escape's Unescape mode instead.
- JSON Escape produces only the sequences JSON defines and targets double quotes. JavaScript Escape also handles single quotes, backticks, template placeholders and angle brackets, so it suits code rather than data.
