JSON String Escape Tool — Escape Strings for JSON

Escape special characters in strings to make them safe for inclusion inside JSON values. Handles backslashes, quotes, newlines, tabs, and Unicode control characters automatically.

Key Features

How to Use

  1. Paste your raw string or code block into the input editor.
  2. Select your desired escape options (e.g. forward slash escaping).
  3. Click "Escape JSON" to sanitize the string.
  4. Copy the escaped string for safe insertion into your JSON object.

Example

Sample input

Line one
Tab	here "quoted"

Sample output

Line one\nTab\there \"quoted\"

Edge Cases

Frequently Asked Questions

Why do double quotes and backslashes need escaping in JSON?

In JSON strings, double quotes delimit the start and end of strings, while backslashes serve as escape initiators. Unescaped quotes cause fatal syntax errors.

Can this tool unescape a string back to normal text?

Yes. Switch to the "Unescape" tab to decode escaped JSON strings back into readable raw text with normal line breaks and quotes.

Is forward slash escaping mandatory in JSON?

No, escaping forward slashes is optional according to RFC 8259, but useful when embedding JSON directly inside HTML <script> tags to avoid premature closing tags.

Related Tools

Privacy notice: when you run this tool, your input is sent over HTTPS to our server, processed in memory and returned. It is not stored or logged. Avoid pasting live secrets such as private keys or passwords.