JSON Tools Hubjsontoolshub.com

JSON Escape

Use JSON Escape when embedding multiline strings or paths inside JSON properties, and switch to Unescape to decode escaped log payloads safely.

JSON Escape & Unescape

Input0 chars
Line 1, Col 1

JSON escape and unescape rules

In Escape mode, raw text (or valid compacted JSON) escapes double quotes (\"), backslashes (\\), newlines (\n), carriage returns (\r), tabs (\t), and control chars using JSON.stringify without wrapping outer quotes. In Unescape mode, quoted string literals ("...") parse strictly via JSON.parse, while unquoted escaped text runs through a single-pass decoder (catching invalid sequences like \q or trailing \ cleanly without corrupting \\n).

Features and output

  • Escapes quotes (\"), backslashes (\\), newlines (\n), returns (\r), tabs (\t), and Unicode cleanly
  • Escape / Unescape mode switcher right in the workspace toolbar
  • Single-pass unescaper decodes exactly one serialization layer without corrupting \\n sequences
  • Reports explicit syntax errors on invalid escapes (e.g. "\q") instead of silently dropping characters

When to use this tool

  • Prepare multiline templates or HTML snippets to paste inside a JSON string field
  • Unescape stringified JSON captured from server logs or database columns one layer at a time
  • Resolve double-encoded JSON responses safely without blindly deleting backslashes

Practical example

Sample Input
He said "hi".
Next\path
Expected Output
He said \"hi\".\nNext\\path

Escape returns inner escaped string content without outer quotes so you can paste directly inside "...". Decode double-encoded strings one click at a time.

Common errors & troubleshooting

  • Unescaping malformed sequences such as "\q" or a trailing dangling backslash returns an explicit error instead of corrupting output.
  • Confusing shell quoting (bash/zsh) or SQL escaping with JSON string encoding (RFC 8259).
  • Repeatedly unescaping multiple times when only one serialization layer was escaped.

Limitations & edge cases

  • Implements JSON string escaping (RFC 8259) only, not bash, PowerShell, URL, HTML, or SQL query escaping.
  • Does not sanitize HTML or protect against SQL injection; always use parameterized database queries.
  • Escape output excludes surrounding quotation marks by design.

Developer tip: For double-encoded payloads like "{\"a\":1}", run Unescape once on the literal string and then check the decoded JSON syntax in JSON Validator.

How to use JSON Escape

  1. 1Paste raw text or an escaped JSON string into the input editor.
  2. 2Select Escape or Unescape in the toolbar toggle.
  3. 3Click Process String (or press Cmd/Ctrl + Enter), verify quote boundaries, and Copy the output.

Privacy note: Processing runs locally in your active browser tab. Avoid pasting live production secrets or tokens.Verified against implementation: November 2026

JSON Escape Reference

Frequently asked questions

Why does JSON output include backslashes?

JSON requires backslashes before double quotes (\"), literal backslashes (\\), and control characters (\n, \r, \t) so parsers know where strings end.

Does Escape mode add surrounding quotation marks?

No. Surrounding outer quotes are omitted so you can paste the escaped characters directly inside an existing "..." string literal.

How do I decode double-encoded JSON safely?

Switch to Unescape mode to decode one serialization layer cleanly, copy the output if another layer remains, and never strip backslashes blindly with search-and-replace.

Is JSON escaping safe for SQL or shell commands?

No. Shell commands, HTML templates, and SQL queries use separate escaping rules; always use parameterized SQL and shell-native argument arrays.

Related tools and contextual links

View all 16 tools →
Check decoded JSON syntax →

Confirm that unescaped text forms valid JSON before using it.

Format the decoded JSON document →

Indent extracted JSON cleanly after decoding serialized logs.

Edit the decoded JSON data →

Modify unescaped properties and re-serialize safely.