Skip to content
Oblicznik

JSON escape and unescape

Turn plain text into a quoted JSON string literal or decode one layer of JSON escape sequences.

Enter data

Escape: plain text. Unescape: one JSON string literal, including its quotes. Fields marked with an asterisk are required.

Maximum 50,000 UTF-16 units. Data is not saved.

About this tool

Text with quotes, backslashes or newlines requires escape sequences inside JSON. Escape returns a complete literal with surrounding quotes. Unescape accepts that literal and returns its contents after one decoding step. The tool does not infer missing quotes or automatically decode further layers.

How to use the calculator

  1. Choose a direction. Keep input quotes in Unescape mode.
  2. Paste text and select “Process”. Empty input is unsupported; the empty literal "" is allowed.
  3. Copy only the output. Spaces and newlines are retained, including leading and trailing whitespace.

Calculation details

Formula and calculation method

Escape = JSON.stringify serialization of text. Unescape = bounded parsing of one JSON string literal; objects, arrays and numbers are errors. Exactly one layer is decoded.

Worked example

Two lines containing “Ala” and “kot” escape to "Ala\nkot". Unescape restores those two lines. Input "" produces empty text, which can be copied.

Limitations

  • Up to 50,000 UTF-16 units per field, 64 container levels and 10,000 values per document. Duplicate member names and unpaired Unicode surrogates, including escaped ones, are rejected. This is a deliberately narrower interoperability profile, not proof of compatibility with every parser.
  • Not Base64, URL encoding, HTML entities or HTML sanitization. Scripts are not executed and input is not rendered as HTML. Escaped output can be longer than input. No files or saved history.
  • Text output is limited to 500,000 UTF-16 units. In comparisons, combined report-path lengths cannot exceed 100,000 units; exceeding a limit gives an error, not a partial result.

Sources

Engine version: 1.0.0 · Last reviewed: 1 October 2026

Frequently asked questions

Are quotes part of the output?

Yes in Escape: the result is a complete JSON literal. Unescape returns its contents without surrounding quotes. Keep quotes before decoding.

Does the result prevent XSS?

No. A valid JSON literal is not automatically safe HTML. Use encoding appropriate to the destination context and do not insert the result through innerHTML.

Can I decode a whole object?

Not here. Unescape requires a single string literal. Use the JSON formatter to check objects and arrays.

Does data leave the browser?

Inputs and results are not sent to a server or analytics or stored in the URL or persistent form storage. Loading the page requires a hosting request. Clipboard copies, printing and browser extensions remain outside reset control. Avoid secrets.

Read the supporting guide

Generator

JSON formatter and validator

Check JSON syntax, add indentation or remove unnecessary whitespace without rounding numbers.

Open tool
Calculator

JSON comparison

Compare two JSON documents and find added, removed or changed members using JSON Pointer paths.

Open tool