Left Input
Right Output
Privacy: Runs locally in your browser. No data uploaded.
Escape omits surrounding quotes. Unescape decodes one layer. See input and output examples.
Ready. Paste text on the left and choose Escape or Unescape.

JSON Unescape & Escape Tool – Unescape or Escape JSON Strings Online

Escape JSON string online or unescape JSON output when you need clean, readable text. Convert quotes, backslashes, tabs, and newlines safely for APIs, logs, and configuration files.

Use this JSON escape and unescape tool when you need to embed human text inside JSON. It converts special characters into JSON-safe escape sequences for APIs, logs, and configuration files, and it reverses those sequences back into readable text when you need to debug or remove backslashes. Escape returns the contents of a JSON string without surrounding quotes. Add double quotes around that output when using it as a JSON value. Unescape returns readable text; it may contain real line breaks and is not necessarily valid JSON. When you are done, you can validate JSON, format JSON, or minify JSON without breaking the escaped values. New to escaping? Read our guide on how to escape and unescape JSON strings.

Updated September 2026 — clarified output quotes, single-pass unescaping and literal backslashes.

What is JSON escaping?

JSON escaping represents characters inside a JSON string using backslash sequences. The reference table below shows the sequences for quotes, backslashes and control characters. A complete JSON string must also be wrapped in double quotes; this tool returns the escaped content so you can place it inside a string value.

Unescaping is the reverse. It converts those escape sequences back into the original characters so the text is readable again. This is useful when you copy a JSON string from logs or API responses and want to see the raw message without the extra backslashes.

JSON escape characters: complete reference table

These are all the escape sequences JSON supports (RFC 8259), including which ones are mandatory:

CharacterEscape sequenceRequired?Notes
Double quote "\"MustInside every JSON string.
Backslash \\\MustCommon in Windows paths and regexes.
Newline (U+000A)\nMustRaw line breaks are invalid in JSON strings.
Carriage return (U+000D)\rMustOften paired with \n in Windows text.
Tab (U+0009)\tMust 
Backspace (U+0008)\bMust 
Form feed (U+000C)\fMust 
Other control chars (U+0000–U+001F)\u00XXMuste.g. \u0000 for NUL — no shorthand exists.
Forward slash /\/OptionalOnly useful when embedding JSON inside </script> HTML.
Any character\uXXXXOptional4-digit hex; characters outside the BMP (emoji) need surrogate pairs, e.g. \uD83D\uDE80 for 🚀.

Everything else — letters, digits, punctuation, even non-ASCII text like café or 日本語 — can appear unescaped in a UTF-8 JSON document. The tool applies the Must rules automatically and offers the optional ones as settings.

When do you need to escape JSON?

Escape JSON when a string contains characters that would otherwise break parsing. Common situations include:

  • Embedding user-generated text that includes quotes, backslashes, or line breaks.
  • Sending multiline messages, stack traces, or log entries inside JSON payloads.
  • Storing configuration values that include tabs, newlines, or Windows file paths.
  • Building test fixtures or fixtures for APIs and webhooks where strict JSON is required.
  • Copying JSON string values from logs where escapes are already present and need to be normalized.

If the value is already a JSON object (not a string), do not escape the whole object—escape only the string fields. After escaping, it is a good idea to validate JSON so you catch syntax issues early.

JSON escape examples (double quotes, backslashes, tabs, newlines)

Paste each input on the left and click Escape → Right. These examples show the exact right-hand output with Escape unicode as \uXXXX unchecked. The tool does not add surrounding quotes.

Double quotes

Input text:

He said "hello"

Escape output:

He said \"hello\"

Backslashes (Windows paths)

Input text:

C:\temp\file.txt

Escape output:

C:\\temp\\file.txt

Tabs and newlines

Input text (a real line break and tab):

Line 1
Line 2	Tabbed

Escape output:

Line 1\nLine 2\tTabbed

Using the escaped output in a JSON payload

A JSON string value needs double quotes around the escaped content, as specified in RFC 8259, section 7. Add those quotes when constructing a payload manually, then validate the complete JSON:

{
  "message": "Line 1\nLine 2\tTabbed",
  "path": "C:\\temp\\file.txt"
}

If your application already serializes the value with a JSON library, give it the original text. Passing the escaped output to that serializer would add another layer of escaping.

How to unescape a JSON string

Paste escaped text on the left and click Unescape → Right to decode one layer. A backslash followed by n becomes a line break; \" becomes a quote; \\ becomes one literal backslash. Unescaping does not mean deleting every backslash.

Input without surrounding quotes

Input (the two characters \n, not a line break):

Line 1\nLine 2

Unescape output:

Line 1
Line 2

Input with surrounding quotes

This tool accepts a quoted string and keeps its surrounding quotes in the displayed output. The decoded line break is real, so this display is not a valid JSON string literal to paste into a payload.

"Line 1\nLine 2"

Unescape output (surrounding quotes retained):

"Line 1
Line 2"

For a complete object or array that needs parsing, use JSON Parse. Unescape is for decoding string content, not repairing or formatting an entire JSON document.

How to decode a double-escaped string

A string can acquire another layer of escaping when it passes through a second serializer. Decode only the number of layers you know were added. Use Unescape again only after checking the output; the button's presence does not prove another pass is needed.

  1. Paste the input below and click Unescape → Right.
  2. Check the first output. For this example, a second layer is known to exist, so click Unescape again. It copies the right output to the left and decodes it once more.

Double-escaped input:

Line 1\\nLine 2

After the first pass (still a literal backslash followed by n):

Line 1\nLine 2

After Unescape again (a real line break):

Line 1
Line 2

Keep literal backslashes in file paths

Unescaping C:\\temp\\file.txt once produces C:\temp\file.txt. Stop there if that is the intended path. Another pass would interpret \t as a tab and \f as a form feed. Do not use Unescape again on that decoded path. Other literal text can also contain intentional backslashes.

JSON escaping vs URL encoding vs HTML encoding

These encodings solve different problems, so it helps to pick the right one. JSON escaping makes a string valid inside JSON. URL encoding is for query strings and URLs. HTML encoding is for safe display in HTML.

Encoding Purpose Example output Use when
JSON escaping Make a string valid inside JSON \", \\n, \\\\ APIs, configs, logs, JSON payloads
URL encoding Make data safe inside a URL %22, %0A Query strings, redirects, path params
HTML encoding Prevent HTML parsing issues &quot;, &#10; HTML text nodes and attributes

If you need to send JSON through a URL parameter, escape the JSON string first, then URL-encode it. If you embed JSON inside HTML, you may also need HTML encoding for safe rendering.

Common issues & debugging

Double escaping (extra backslashes)

Repeated backslashes can represent another serialization layer or intentional text. Compare the two-pass example with the source of your data before decoding again. Stop when the result matches the intended value.

Invalid escape sequences

JSON supports a limited set of escape sequences: \\\", \\\\, \\/, \\b, \\f, \\n, \\r, and \\t. Sequences like \\q or \\x are invalid in JSON and will throw errors.

“Unexpected token” errors

This usually means the JSON parser hit an unescaped quote or a raw newline inside a string. Escape the value so the string stays on one line, then validate JSON before sending the payload.

Unicode escape sequences (e.g., \\u263A)

Unicode escapes must be four hex digits. \\u263A is valid (☺), but \\u00G1 is not. Emojis may require surrogate pairs (for example, \\uD83D\\uDE80 for 🚀). If a character looks broken, check the hex digits first.

If you need to compare raw and escaped output side by side, use Compare Clips to spot differences quickly.

Language snippets (short + accurate)

These snippets show typical, correct ways to escape and unescape JSON strings in popular languages.

JavaScript

const input = 'Line 1\\n"quote"';
const escaped = JSON.stringify(input);
const unescaped = JSON.parse(escaped);

Python

import json

text = 'Line 1\\n"quote"'
escaped = json.dumps(text)
unescaped = json.loads(escaped)

Java (Jackson)

ObjectMapper mapper = new ObjectMapper();
String text = "Line 1\\n\\\"quote\\\"";
String escaped = mapper.writeValueAsString(text);
String unescaped = mapper.readValue(escaped, String.class);

C# (.NET)

using System.Text.Json;

string text = "Line 1\\n\"quote\"";
string escaped = JsonSerializer.Serialize(text);
string unescaped = JsonSerializer.Deserialize<string>(escaped);

Go

b, _ := json.Marshal("Line 1\n\"quote\"")   // escape
var s string
json.Unmarshal(b, &s)                        // unescape

PHP

$escaped   = json_encode("Line 1\n\"quote\"");   // escape
$unescaped = json_decode($escaped);              // unescape

FAQs

Is JSON escaping the same as URL encoding?
No. JSON escaping uses backslashes (\\\", \\n) for JSON strings, while URL encoding uses percent codes like %22 and %0A for URLs.

Should I escape an entire JSON object?
Only if you need to store the whole JSON document as a string value. Otherwise, keep the object as JSON and escape only the string fields.

Why do I see double backslashes?
They may represent a literal backslash or another serialization layer. Decode one known layer at a time and check the result; do not remove backslashes that belong in a path or other text.

Does this tool handle Unicode like \\u263A?
Yes. Unicode escape sequences are supported as long as they use valid 4-digit hex. Emojis may require surrogate pairs.

Can I escape multiline text with tabs and newlines?
Yes. Tabs become \\t and newlines become \\n so the string remains valid JSON.

Is my data uploaded?
No. Everything runs locally in your browser, so your text never leaves your device.

What causes “Unexpected token” errors?
They usually come from unescaped quotes or raw newlines inside a JSON string. Escape the value and validate JSON before sending it.

How do I escape a JSON string?
Paste raw text on the left and click Escape. The output escapes quotes, backslashes, newlines and tabs without adding surrounding quotes. Add double quotes when using it as a JSON value; if a JSON library serializes for you, give that library the original text instead.

How do I unescape a JSON string?
Paste escaped text on the left and click Unescape to decode one layer. Input can have surrounding quotes or none; this tool retains surrounding quotes in the displayed output. Decoded text can contain real line breaks and is not necessarily valid JSON.

How do I escape double quotes in JSON?
Each double quote inside a JSON string must be preceded by a backslash. This tool does it automatically when you click Escape, and Unescape reverses it.

How do I fix a double-escaped JSON string?
Click Unescape once, inspect the output, and use Unescape again only when another serialization layer is known to remain. That button copies the output to the input and decodes one more layer. Stop before changing intentional backslashes, such as those in a Windows path.

What characters must be escaped in JSON?
Double quotes, backslashes, and the control characters newline, carriage return, tab, backspace and form feed must be escaped. The forward slash may optionally be escaped.