JSON Escape/Unescape Online

Escape and unescape JSON strings. Fast, secure, and completely free. All processing happens in your browser — no data is sent to any server.

What is JSON Escape/Unescape?

JSON escaping converts special characters — double quotes, backslashes, newlines, tabs — into their backslash-escaped equivalents (\", \\, \n, \t) so a string can be safely embedded as a JSON string value without breaking the surrounding structure. This is different from formatting a JSON document; it's specifically about taking a raw piece of text (like a multi-line log message or a snippet of code) and turning it into something that can sit inside a JSON string literal without prematurely closing the quotes or corrupting control characters.

How to Use JSON Escape/Unescape

  1. Paste the raw text you want to embed inside a JSON string — logs, code snippets, or plain text with special characters
  2. Click 'Escape' to convert quotes, backslashes, and control characters into their JSON-safe equivalents
  3. Copy the escaped string and wrap it in quotes to use as a JSON value
  4. Use 'Unescape' to reverse the process when reading an escaped string back into readable text
  5. Verify the round-trip by unescaping your own output — it should match the original exactly

Key Features

Why Use JSON Escape/Unescape?

Embedding arbitrary text inside a JSON string by hand is a common source of subtle bugs: a stray double quote breaks the JSON structure, an unescaped backslash from a Windows file path (C:\Users\...) gets misread, and a raw newline inside a string literal is actually invalid JSON. This tool handles all of those cases correctly in one pass, which matters most when you're constructing JSON payloads manually, embedding log messages or code snippets as string values, or debugging why a hand-written JSON string won't parse.

Common Use Cases

Frequently Asked Questions

What's the difference between this and the JSON Formatter?

The formatter re-indents a whole valid JSON document; this tool escapes or unescapes a single piece of raw text so it can safely become one JSON string value, which is a different, more granular operation.

Why does a backslash become two backslashes after escaping?

Backslash is JSON's escape character, so a literal backslash must itself be escaped as \\ or the parser would treat the character after it as the start of an escape sequence.

Can I escape text containing emoji?

Yes — most emoji pass through unescaped since they're valid inside JSON strings, though the tool correctly escapes any control characters mixed into the same text.

What happens if I try to unescape text that isn't actually escaped?

Since there's nothing to unescape, the output matches the input unchanged — unescaping only affects recognized backslash sequences.

Does escaped text still need to be wrapped in quotes to be valid JSON?

Yes — escaping only prepares the inner content; you still need to add the surrounding double quotes yourself to form a complete JSON string value.

Guides

Related Tools