JSON Escape / Unescape

What is a JSON Escape / Unescape?

Escape plain text strings so they can be embedded safely inside JSON string literals (escaping quotes `\"`, newlines `\n`, tabs `\t`, and backslashes `\\`), or unescape JSON string literals back to raw unescaped text.

Why Use This Tool?

  • Embedding Text in JSON Payloads: Safely embed multi-line text, HTML, or code snippets into JSON API payloads.
  • Fix JSON Escaping Errors: Unescape double-escaped JSON string fields from server logs or database entries.
  • Environment Variable Formatting: Format string variables for JSON configuration files.

How to Use

  1. Select Action: "Escape for JSON" or "Unescape from JSON".
  2. Paste your input text string.
  3. Copy the escaped or unescaped string result.

Real Working Example

Input:

Plain Text: Hello "World"
Line 2

Output Result:

Escaped JSON String: Hello \"World\"\nLine 2

Important Technical Details & Specifications

  • JSON String Specification Engine: Replaces `"` with `\"`, `\` with `\\`, `\n` with `\n`, `\r` with `\r`, and `\t` with `\t`.
  • Reverse Unescaping Parser: Uses `JSON.parse(""" + input + """)` to restore raw text strings.
  • Local Memory Processing: Zero network overhead.

Related Developer Tools

Frequently Asked Questions

Why do double quotes need to be escaped in JSON?

Double quotes denote the boundary of string values in JSON; unescaped double quotes inside strings break JSON syntax.

How are newlines represented in escaped JSON?

Literal line breaks are converted to the two-character sequence `\n`.

Is it free?

Yes, 100% free.

Are my text strings sent to a server?

No, escaping and unescaping happens 100% locally in your web browser.

Can it unescape double-escaped JSON strings?

Yes, select Unescape mode to strip extra backslashes.