Skip to content
ToolsOnDuty - free online tools
Developer Tools

JSON Escape / Unescape

Escape text into a JSON string or unescape a JSON string back to text.

Free browser toolRuns in your browserNo sign-up
JSON string transformation

Escape text for a JSON string—and reverse it exactly

Convert quotes, backslashes, tabs, line breaks and control characters into JSON string escapes, or decode a valid escaped string body back to text.

Escape text

mode

24 B

input size

29 B

output size

Raw text

24 characters

Escaped string body

29 characters

The escaped result is a JSON string body, not a complete JSON document with surrounding quotes.

Private by design. Input is processed inside this browser tab and is not sent to ToolsOnDuty.

About the JSON Escape / Unescape

When you embed text inside a JSON string, special characters like quotes, backslashes, newlines and tabs must be escaped, or the JSON becomes invalid.

This tool escapes any text into a safe JSON string body, and unescapes an escaped string back into the original text.

It runs entirely in your browser, so your data stays private.

Key features

  • Escape text to a JSON string body
  • Unescape back to raw text
  • Handles quotes, newlines, tabs and unicode
  • Explicit invalid escape-sequence errors
  • Copy, download or reuse the result
  • Local, private processing

How to use

  1. 1Choose Escape or Unescape.
  2. 2Paste your text or load the realistic sample.
  3. 3Review any invalid escaped-string error.
  4. 4Copy, download or reuse the result as input.

Examples

Escape a multi-line string
Input: Line 1\nLine 2
Output: Line 1\\nLine 2

The newline becomes \n so the text is safe inside a JSON string.

Frequently asked questions

What characters get escaped?
Double quotes, backslashes and control characters such as newlines and tabs become their escape sequences (\", \\, \n, \t), so the result is a valid JSON string body.
Does it add the surrounding quotes?
No. It returns the escaped body without the outer quotes, so you can drop it straight into a JSON string.
Why does unescape show an error?
If the input is not a valid escaped string (for example a stray backslash), it cannot be parsed. Fix the escape sequences and try again.

Open a related tool to prepare your files or refine the finished result.