JSON Escape

Escape text into a valid JSON string literal.

JSON Runs in your browser
Text or JSON
Escaped string

Nothing escaped yet

Paste any text to get a valid JSON string literal you can drop straight into a document.

Runs entirely in your browser. Your data isn't uploaded — this page makes no network request with anything you type, which you can verify in your browser's network tab. How this works.

What is the JSON Escape?

Sometimes a JSON document has to travel inside another JSON document — a payload stored in a string field, a request body embedded in a test fixture, a template variable. To do that safely the text has to be escaped into a valid JSON string literal.

This tool does exactly that: quotes, backslashes, newlines, tabs and control characters become their escape sequences, and you get back a single string you can paste anywhere a JSON string is expected.

How to use it

  1. Paste the text or JSON you want to embed.
  2. Choose whether to include the surrounding double quotes.
  3. Press Escape (or Ctrl/Cmd + Enter).
  4. Copy the escaped string.

Example

A JSON document escaped so it can live inside a JSON string field.

Input
{"ok": true}
Result
"{\"ok\": true}"

Features

  • Escapes ", \\, newlines, carriage returns, tabs and control characters
  • Optional surrounding quotes so the result drops straight into a document
  • Optional \\uXXXX escaping of all non-ASCII characters for ASCII-only transports
  • Optional forward-slash escaping for values embedded in HTML script tags

Frequently asked questions

When do I need to escape forward slashes?
Almost never for JSON itself — \\/ and / are equivalent. It matters when JSON is embedded in an HTML <script> block, where the sequence </ can terminate the element early.
Should I escape non-ASCII characters?
Not usually. JSON is UTF-8 by default and modern stacks handle it fine. Turn it on when a legacy system mangles anything outside ASCII.
Esc

Loading the catalog…