← All tools
// DATA FORMATS

JSON Escaper online

Escape or unescape special characters in JSON strings — backslashes, quotes, newlines, tabs.

JSON String Escaper / Unescaper logo
by
CHUNKY
MUNSTER
INPUT STRING0 CHARS
ESCAPED OUTPUT0 CHARS

About JSON String Escaping

In JSON, certain characters inside string values must be escaped with a backslash. This tool escapes and unescapes those characters so you can safely embed any text inside a JSON string value.

Characters escaped

How to Use the JSON String Escaper / Unescaper

  1. Pick the Escape or Unescape tab depending on direction.
  2. Paste your text into the input panel — character counts update live.
  3. Click the action button to convert; the result appears in the output panel.
  4. Use Swap ⇅ to send the output back to the input and flip the mode in one step.

JSON's string grammar is small but strict: inside a quoted value only a few characters are allowed raw, and everything else must be backslash-escaped. This tool covers the five escapes you actually hit in practice — \\, \", \n, \r and \t — in both directions, so you can take a snippet of HTML, SQL or Markdown and drop it inside a JSON config without breaking the parser.

How the JSON String Escaper / Unescaper Works

Unescape mode is implemented on top of JSON.parse: your input is wrapped in quotes and handed to the browser's native parser, which is the only way to be spec-correct about edge cases like \uXXXX unicode escapes, \b and \f. If the parser rejects the input (for example, it contains an unescaped quote), a regex fallback recovers the common cases. The Swap ⇅ button flips both the buffers and the mode so the natural escape-then-unescape workflow round-trips cleanly.

Frequently Asked Questions

When do I need to escape a string for JSON?

Whenever the string is going inside another JSON document — for example a SQL query stored in a JSON config file, or an HTML snippet inside a JSON API payload. JSON only allows certain characters raw inside string literals; everything else must be escaped with a backslash.

Why does unescape use JSON.parse?

Because reimplementing JSON's string grammar by hand misses cases like \u0041 unicode escapes and \b/\f. Wrapping your input in quotes and handing it to JSON.parse is the spec-correct decoder — and if it fails, the tool falls back to a regex-based unescape so common cases still work.

What about Unicode characters above U+FFFF?

JSON encodes them as a UTF-16 surrogate pair (\uD83D\uDE00 for 😀). The escape mode here does not force ASCII-only output, so emoji and other non-ASCII characters pass through verbatim. If you need pure ASCII, post-process with a \uXXXX escaper.

Why does Swap ⇅ also flip the mode?

Because the natural workflow is: escape → use → paste back → unescape. Swapping the buffers without flipping the mode would re-escape an already-escaped string and double the backslashes.

Explore the full suite of DATA FORMATS tools and 290+ other free utilities at Chunky Munster.