Skip to content

JSON Escaper

Escape quotes, backslashes, newlines and control characters for use inside a JSON string, or unescape JSON escape sequences back to plain text.

Runs in your browser Free, no sign-up
Loading tool workspace...

What is JSON Escaper?

This JSON escape and unescape tool converts text so it can be placed inside a JSON string, and back. JSON strings are wrapped in double quotes, so a double quote inside the text must be written as \", a backslash as \\, a line break as \n and a tab as \t. Escaping applies those rules for you, which is useful when you are putting a message, a template, a snippet of code or a file's contents into a JSON value by hand.

Unescaping reverses the process: paste text full of \n, \" and \u00e9 sequences, as found in logs and API payloads, and get the readable original back.

How to use JSON Escaper

  1. Choose Escape to make text safe for a JSON string, or Unescape to turn escaped text back into plain text.
  2. Paste your text into the input panel.
  3. Copy the result from the output panel.
  4. When escaping, wrap the result in double quotes where you place it in your JSON.

Key features

  • Escapes quotes, backslashes, newlines, tabs and control characters
  • Unescapes all JSON escape sequences, including \uXXXX
  • Output follows RFC 8259 exactly
  • Clear error for malformed escape sequences
  • Runs entirely in your browser

Common use cases

  • Putting multi-line text, templates or code into a JSON value
  • Reading escaped strings in JSON logs and API payloads
  • Escaping error messages and stack traces for JSON responses
  • Preparing request bodies with quotes and newlines by hand
  • Fixing JSON that broke because of an unescaped quote

Technical details & standards

Escaping uses JSON.stringify and removes the surrounding quotes, so the output follows RFC 8259 exactly: " becomes \", \ becomes \\, line breaks become \n and \r, tabs become \t, and other control characters become \u00XX sequences. Non-ASCII characters are kept as is, which is valid in UTF-8 JSON.

Unescaping parses the input as the contents of a JSON string, so it understands every JSON escape, including \uXXXX sequences and surrogate pairs for emoji. Invalid sequences, such as a single backslash before an ordinary letter, produce a "Malformed escaped string" error. To turn a whole JSON document into a string, use JSON Stringify.

Frequently asked questions

Which characters need to be escaped in JSON?

Inside a JSON string, the double quote (\"), the backslash (\\) and control characters such as newline (\n), carriage return (\r) and tab (\t). Other characters, including forward slashes and non-English letters, can appear as they are.

How do I escape double quotes in JSON?

Put a backslash before each one: He said "hi" becomes He said \"hi\". Paste the text into Escape mode to do it automatically.

What is the difference between JSON Escape and JSON Stringify?

JSON Escape escapes any text without adding quotes. JSON Stringify takes a JSON document, can compact it, and wraps the whole thing in quotes, producing a complete string literal.

How do I escape or unescape a string with JSON.stringify and JSON.parse?

In JavaScript, JSON.stringify(text).slice(1, -1) escapes text without the surrounding quotes, so He said "hi" becomes He said \"hi\", and JSON.parse('"' + escaped + '"') turns it back. In Python, json.dumps(text, ensure_ascii=False)[1:-1] and json.loads('"' + escaped + '"') do the same. To turn a whole JSON document into a string, use JSON Stringify.

How do I escape a backslash in JSON?

Write it twice: the Windows path C:\Users becomes "C:\\Users" in JSON. A single backslash starts an escape sequence, so one followed by an ordinary letter makes the JSON invalid.

Why do I see \u00e9 instead of é?

Some serializers escape non-ASCII characters as \uXXXX sequences. Both forms are valid JSON; paste the text into Unescape mode to see the readable characters.

Is my data safe?

Processing happens locally in your browser. Tool input is not sent to CodeUnpack servers.

Does it work offline?

Once the page has loaded, this tool can process input without an internet connection.

More encoders & decoders tools

View all