JSON Escape and Unescape Online: Quotes and Newlines

2026-08-04

Why escape JSON strings

Embedding text with quotes, newlines, or backslashes inside a JSON field requires proper escaping—or parsing fails. Logs full of \n and \" also need unescaping to read.

ComTools JSON Escape (Tools/Json/Escape) runs escape / unescape locally, with an optional forced \uXXXX Unicode mode.

Modes

Mode Effect
Escape Plain text → JSON string body (no surrounding quotes)
Unescape Escaped fragment → original text
Force Unicode Emit \uXXXX for non-ASCII when escaping
Swap Swap input/output and flip escape/unescape

Escape ≈ JSON.stringify(text) without outer quotes; unescape ≈ JSON.parse('"' + text + '"').

Steps

  1. Open JSON Escape.
  2. Choose Escape or Unescape; enable Force Unicode if needed.
  3. Paste text on the left (or Sample).
  4. Click Run and copy the result.
  5. Use Swap to convert back and forth.

Nothing is uploaded.

Escape example

Input:

He said "hello"
Line 2

Output sketch:

He said \"hello\"\nLine 2

Embed as:

{ "msg": "He said \"hello\"\nLine 2" }

Unescape example

Input He said \"hello\"\nLine 2 restores real quotes and newlines.

Common scenarios

Scenario Tip
Nested text in config Escape, then paste into a field
Unreadable log escapes Unescape
ASCII-only transport Force Unicode
Whole document invalid Use the validator
Pretty-print a tree Formatter

Notes

  • This tool edits string content, not full-document formatting.
  • Unescape needs valid escape sequences; broken \u fails.
  • Do not “escape” an entire {...} object unless you intend to embed that JSON as a string.

FAQ

Why no surrounding quotes?
Output is the field interior only—you add the outer quotes in JSON.

Will Chinese become \u?
Usually kept as-is unless Force Unicode is on.

Escape a whole object?
Minify first, then escape that one-line string.


中文版