JSON Escape / Unescape

Runs 100% in your browser

Escape raw text for a JSON string or unescape JSON string content back to readable text. Handle quotes, backslashes, control characters, Unicode, line breaks, tabs, and optional slash escaping privately in your browser.

INPUT

Raw text to escape

0 characters
0 bytes 0 lines
OUTPUT

Escaped JSON string

Waiting
0 bytes No output
Input bytes0
Output bytes0
Escapes0
Unicode escapes0
Line breaks0
ModeEscape
JSON string escaping only

This tool handles JSON string content — quotes \", backslashes \\, tabs \t, line breaks \n, control characters, and optional Unicode or slash escaping. It is not URL encoding, HTML entity encoding, Base64, SQL parameterization, or XML escaping. Use the correct context-specific tool for each format.

SESSION HISTORY

Recent local conversions

No conversions in this session yet.
Private by architecture

Escaping, unescaping, validation, and statistics run entirely in your browser. Input is not uploaded, sent to an API, stored in localStorage, or included in analytics. Disconnect your internet after page load and the tool works identically.

Frequently asked questions

A JSON escape tool converts raw text into content that can safely appear inside a JSON string, including escaped quotes, backslashes, line breaks, tabs, and control characters. An unescape tool reverses valid JSON escape sequences back to readable text.

Choose Escape text, paste the raw text, select whether the result should be wrapped in JSON quotes, and the tool converts automatically. It escapes characters that have special meaning in JSON strings while preserving ordinary Unicode unless Unicode escaping is enabled.

Choose Unescape JSON string, paste either escaped content such as Hello \"world\" or a complete quoted JSON string literal, select the matching input format, and the tool decodes automatically. It validates escape sequences before decoding.

Double quotes and backslashes must always be escaped. JSON requires control characters such as backspace, form feed, line feed, carriage return, and tab to use their named escape forms. Other characters below U+0020 use \u Unicode escapes, while forward slashes are optional.

Yes. Literal line breaks become \n, carriage returns become \r, tabs become \t, backspace becomes \b, and form feed becomes \f. This prevents raw control characters from making a JSON string invalid when the text is embedded in a JSON document.

Yes. Keep Unicode for readable UTF-8 JSON or enable Escape non-ASCII as \u sequences to represent every character above U+007F as a \uXXXX escape. Characters outside the Basic Multilingual Plane such as emoji are represented through their UTF-16 surrogate pair escapes when Unicode mode is enabled.

Usually no. The JSON specification does not require forward slashes to be escaped inside strings. Some legacy HTML-embedding or script-injection prevention contexts use \/ defensively. The workspace makes slash escaping an opt-in option rather than applying it silently.

Escaped content contains the inside of a JSON string without surrounding double quotes. A complete JSON string literal includes the opening and closing quotes. The unescape mode supports both formats so you can work with a value copied from inside a JSON document or with the entire quoted literal.

No. This tool focuses on JSON string content only. Use JSON Validator when you need to validate an object, array, number, boolean, null, or a complete multi-value JSON document. A correctly escaped string value can still be placed inside an invalid surrounding document.

No. JSON escaping represents special characters inside JSON strings using backslash sequences. URL percent-encoding represents bytes in URL components. Base64 represents binary or text data using a 64-character transport alphabet. Use the dedicated ToolsSonic tool for each format.

Not safely as a general rule. JSON escaping is context-specific and does not replace HTML entity encoding, JavaScript string literal handling, SQL parameterization, XML escaping, or sanitization. Use the appropriate context-specific encoder for each output language or protocol.

Yes. After a successful conversion, Copy output places the result on your clipboard and Download saves a plain text file containing the exact output. The input remains in browser memory and is not sent anywhere.

No. Escaping, unescaping, validation, and statistics run locally in your browser using built-in string APIs. ToolsSonic does not upload the input, call a remote conversion API, or persist it in localStorage or sessionStorage. Clipboard and shared-device privacy remain separate considerations.

It means the unescape input contains a backslash sequence that JSON does not recognize, such as an incomplete \u escape, an unescaped literal quote inside a JSON string literal, or an unsupported letter after a backslash like \q. The tool stops before decoding and shows the parser error with an approximate line and column position.

What is JSON Escape / Unescape?

A JSON Escape / Unescape tool converts raw text into JSON-safe string content or decodes valid JSON escape sequences back to readable text. It is useful when building request bodies, embedding text in JSON, debugging parser errors, reviewing API logs, and moving values between application code and JSON fixtures.

Why JSON String Escaping Matters

When you paste a string value directly into JSON without escaping it, any double quote terminates the string prematurely, any backslash starts an unintended escape, and any raw line break makes the document invalid. JSON requires seven named escapes — \" \\ \b \f \n \r \t — plus \uXXXX Unicode escapes for control characters and optionally for non-ASCII characters. Getting even one character wrong produces a JSON syntax error that breaks every consumer of the document.

This matters most in three practical situations: (1) constructing JSON strings programmatically and needing to verify the escaping before sending, (2) copying a string value out of a JSON log or API response and needing to decode its escape sequences back to readable text, and (3) debugging a JSON parse error that originates from an unescaped character buried inside a long string value.

What ToolsSonic's JSON Escape / Unescape Workspace Provides

Bidirectional conversion with explicit modes. Choose Escape text to convert raw characters to JSON-safe sequences, or Unescape JSON string to decode sequences back to readable text. The workspace updates input/output labels, disables irrelevant controls, and runs the conversion automatically as you type.

Input format control for unescape. Competitors accept only escaped content. ToolsSonic also accepts a complete quoted JSON string literal — the kind you copy from an actual JSON document including the surrounding double quotes. This eliminates the most common user error: pasting "Hello \\"world\\" and getting a parse failure because the surrounding quotes were not expected.

Quote wrapping option. Escape mode can return either bare escaped content for embedding inside a surrounding string context, or a complete JSON string literal with surrounding double quotes for direct pasting into a JSON document. The output is the same characters either way; the wrapping makes the result immediately usable without an extra step.

Optional forward-slash escaping. The JSON specification allows but does not require \/ for forward slashes. Legacy HTML-embedding contexts and some JSONP implementations use it to prevent </script> injection. ToolsSonic exposes this as an opt-in checkbox so you can apply it for specific deployment contexts without it becoming the default.

Optional non-ASCII Unicode escaping. Keep Unicode for readable UTF-8 JSON or enable Escape non-ASCII as \u sequences to represent every character above U+007F as a four-digit \uXXXX escape. Characters outside the Basic Multilingual Plane — including most emoji — are handled as UTF-16 surrogate pairs when this mode is enabled.

Diagnostics with approximate position. When an invalid escape sequence is detected in unescape mode, the tool extracts the parser position, computes the line and column, and reports both. Competitors show a generic error message or no error at all. ToolsSonic shows exactly where the parse failed so you can fix the specific character without inspecting the entire input.

Six-stat bar. Input bytes, output bytes, total escape count, Unicode escape count, line-break count, and current mode give a precise picture of every conversion without leaving the page.

JSON Escaping vs Other Encoding Formats

JSON escaping is often confused with related but distinct encoding operations. The choice of the wrong tool produces silently wrong output in every case.

| Format | Use when | Example | |---|---|---| | JSON string escaping | Embedding text inside a JSON string | "Hello \\"world\\" | | URL percent-encoding | Encoding characters in URL components | Hello%20%22world%22 | | HTML entity encoding | Escaping characters for HTML output | Hello &quot;world&quot; | | Base64 encoding | Transport-safe binary or text encoding | SGVsbG8gIndvcmxkIg== | | SQL parameterization | Preventing SQL injection | Use prepared statements |

ToolsSonic provides dedicated tools for URL encoding, HTML entity encoding, and Base64, all linked from the JSON Escape / Unescape page.

Common use cases

  • Escaping quotes, backslashes, tabs, and line breaks before inserting text into JSON
  • Unescaping a JSON string value copied from an API response, log, or document
  • Representing control characters below U+0020 with valid JSON escape sequences
  • Converting Unicode characters to \u escapes for ASCII-only JSON transport
  • Checking whether a complete JSON string literal parses without errors
  • Preparing fixture string values and payload fragments for automated tests
  • Debugging a JSON parse error caused by an unescaped character in a string
  • Copying or downloading escaped text without uploading sensitive content

Why use ToolsSonic's JSON Escape / Unescape?

ToolsSonic's JSON Escape / Unescape workspace addresses the main gaps versus DevTools Daily, Code Beautify, Online JSON Tools, and Browserling: explicit escaped-content versus complete-JSON-string input formats, optional quote wrapping, optional slash escaping, optional non-ASCII Unicode escaping including UTF-16 surrogate pairs, line/column diagnostics, byte and escape count statistics, session history, copy/download, local file support, and context warnings that clearly distinguish JSON string escaping from URL encoding, HTML entities, Base64, and SQL. Every operation runs locally in the browser with no upload and no persistence.

JSON String Escape Sequence Reference

The JSON specification defines seven named escape sequences and a Unicode escape form.

| Input character | JSON escape | When it appears | |---|---|---| | Double quote " | \\" | Inside any JSON string value | | Backslash \\ | \\\\ | Any literal backslash | | Backspace | \\b | Legacy teletype control character | | Form feed | \\f | Page break control character | | Line feed (newline) | \\n | Multi-line string values | | Carriage return | \\r | Windows-style line endings | | Tab | \\t | Literal tab characters | | Control chars U+0000–U+001F | \\uXXXX | Any C0 control character | | Forward slash / | \\/ | Optional; for legacy HTML embedding | | Non-ASCII (optional) | \\uXXXX | When ASCII-only output is required |

The backslash and double quote escapes are mandatory in every JSON string context. The named control escapes (\\b \\f \\n \\r \\t) are required for those specific code points. Forward slash and non-ASCII escaping are always optional.

100% private — runs in your browser Instant — no server round-trip Free forever — no account needed