DevKitBase
ToolsAboutPrivacy

Escape text so it can live inside a JSON string

Dropping raw user text into a hand-built JSON string is how you break parsers. Paste the raw string; get the escaped form ready for `"..."`.

chars: 32
Input
Output

When to use

Building examples by hand, embedding paths in JSON strings, or fixing copy-paste into config files.

Examples

Input
He said "hi"
Output
He said \"hi\"
Input
line1
line2
Output
line1\nline2

How it works

Escapes control characters and quotes for a JSON string body (JSON.stringify(raw).slice(1,-1) style). It does not wrap the whole document as an object.

Common pitfalls

  • Escaping ≠ encoding (use Base64/URL tools for that).
  • Don’t double-escape already escaped text.
  • Backslashes in Windows paths need care.

How this differs

Escape prepares string contents; Unescape reverses. HTML Encode is for markup entities, not JSON strings.

FAQ

Do I need to escape keys too?
Keys follow the same string rules.
Is this HTML escaping?
No — use HTML Encode for entities.
Unicode?
Prefer `\uXXXX` only when needed; modern JSON allows UTF-8 in strings.
Reverse?
JSON Unescape.

Related tools

Runs in your browser. Nothing is uploaded. Not a security product —hashes and JWT decode are for debugging, not password storage or auth advice.