Skip to content

JSON Escape

Turn any text, even a whole JSON document, into a safe string you can embed inside another JSON value.

Processed locally in your browser

Options
0 chars · 0 lines
The result will appear here.

What is JSON Escape?

Inside a JSON string, a few characters must be written with a backslash: the double quote, the backslash itself and control characters such as line breaks and tabs. When you paste a multi-line message, a Windows path or a JSON snippet into a JSON field, forgetting to escape them produces an invalid document.

This tool applies the exact JSON string escaping rules (\", \\, \n, \r, \t, \b, \f and \u00XX for other control characters). You can also wrap the result in double quotes, escape every non-ASCII character as \uXXXX for ASCII-only transport, and escape the slash as \/ when embedding into HTML script tags.

How does it work?

  1. Paste the text (or JSON) you want to embed.
  2. Tick “Wrap in double quotes” if you need a complete JSON string literal.
  3. Optionally enable \uXXXX escaping for non-ASCII characters or the \/ slash escape.
  4. Copy the escaped string, or click Swap to check it with JSON Unescape.

Common use cases

  • Putting a JSON payload inside the "body" field of another JSON request.
  • Adding a multi-line error message or a Windows path to a JSON configuration.
  • Producing ASCII-only JSON strings for systems that mishandle UTF-8.
  • Preparing text for a JSON string in source code or a test fixture.

Examples

Try this input in the tool above:

Input
{"message": "He said \"hi\"", "path": "C:\\temp", "emoji": "café ☕"}
Output
{\"message\": \"He said \\\"hi\\\"\", \"path\": \"C:\\\\temp\", \"emoji\": \"café ☕\"}

Privacy

JSON Escape runs entirely in your browser. The text or files you provide are processed on your device and are not uploaded, logged or stored on our servers.

Limitations

Escaping is not encryption and not a security sanitiser for HTML or SQL; it only makes text valid inside a JSON string.

Frequently asked questions

Should I wrap the result in quotes?

Only if you need the full literal, for example to paste it as a value. If you are typing between existing quotes in a JSON file, leave the option off.

Which characters are escaped?

The double quote, the backslash and all control characters below U+0020. Non-ASCII text stays readable unless you enable the \uXXXX option; lone surrogates are always escaped.

How do I embed a JSON document inside a JSON string?

Paste the inner document, enable “Wrap in double quotes”, and use the result as the value. Every inner quote becomes \" so the outer JSON stays valid.

More tools in JSON & Data →