IMAGE BASE64 TOOLBase64 decoder

JSON Escape

JSON escape converts text to one complete double-quoted JSON string, or restores that string to text; quotes, backslashes, control characters and Unicode escapes follow JSON string rules.

Ready. Empty text is supported in the text-to-JSON direction.

No conversion yet.

Six original strings, two escape modes

We authored six strings covering quotes, a backslash path, a real line break, real control characters, CJK text and supplementary emoji. JavaScript serialized each input in both modes and parsed each output back to the exact source string. Python’s separate JSON implementation produced the same escaped strings and restored the same source strings in every row. The table is generated from those actual runs.

SampleSource shown visiblyJSON stringASCII-only JSON stringUTF-16 units: source / JSON / ASCII-only
1
He said "yes".
"He said \"yes\"."
"He said \"yes\"."
14 / 18 / 18
2
C:\notes\one.txt
"C:\\notes\\one.txt"
"C:\\notes\\one.txt"
16 / 20 / 20
3
Line one[LF]Line two
"Line one\nLine two"
"Line one\nLine two"
17 / 20 / 20
4
A[TAB]B[BS]C[FF]D[CR]E[NUL]F
"A\tB\bC\fD\rE\u0000F"
"A\tB\bC\fD\rE\u0000F"
11 / 22 / 22
5
中文样本
"中文样本"
"\u4e2d\u6587\u6837\u672c"
4 / 6 / 26
6
Launch 🚀🙂
"Launch 🚀🙂"
"Launch \ud83d\ude80\ud83d\ude42"
11 / 13 / 33
Measured UTF-16 unit counts for sample group 1
Input and output UTF-16 unit counts for this sample group.
Measured UTF-16 unit counts for sample group 2
Input and output UTF-16 unit counts for this sample group.
Measured UTF-16 unit counts for sample group 3
Input and output UTF-16 unit counts for this sample group.
Measured UTF-16 unit counts for sample group 4
Input and output UTF-16 unit counts for this sample group.

Bracketed markers such as [LF] and [TAB] make the source controls visible in the table. They were actual control characters in the tested inputs, not literal marker text. Both escape modes passed exact roundtrip checks for every source. The unit counts were read from JavaScript strings; Python generated independent serialization and parsing results, not a copied reference table.

The CJK row contains four Unicode scalar values. The emoji row includes two supplementary scalar values, each stored as two UTF-16 units. ASCII-only output writes each UTF-16 unit as a four-hex-digit escape, so the rocket becomes a paired escape rather than one six-digit escape. The output is different notation for the same text, not a change in the text.

We additionally verified the empty source string, a valid rocket surrogate pair, and the literal sequence containing percent notation, an entity-shaped string and U+ notation. Those context markers remained literal. Invalid escape letters, brace-style Unicode escapes, raw newlines inside a quoted string and non-string JSON values were rejected. An unpaired surrogate was rejected by this tool’s explicit Unicode-scalar policy; this policy is stricter than simply accepting every possible JSON string escape.

To reproduce a row, enter the source with the stated real controls, select Text to JSON string and compare its output. Repeat with ASCII-only output checked. Paste either full quoted output into JSON string to text and compare the restored characters, including line breaks and spaces. This test compares exact character sequences, not appearance or an accuracy percentage.

Which characters are escaped?

Double quotes become backslash-quote, and backslashes are doubled. The standard short escapes are \b for backspace, \f for form feed, \n for line feed, \r for carriage return and \t for tab. Other controls below U+0020 use \uXXXX. Ordinary forward slashes remain literal when escaping; the valid \/ form is also accepted when restoring a JSON string.

Unicode notation and escapes

JSON uses exactly four hexadecimal digits after \u; supplementary characters can use a valid UTF-16 surrogate pair. ASCII-only output also escapes non-ASCII characters and DEL. By default readable Unicode stays readable. U+0041 is a code-point label, not a JSON escape; \u{41}, \x41 and octal escapes are not JSON string syntax. This tool requires paired surrogates and rejects unpaired ones instead of silently changing text.

Different contexts stay separate

JSON string escaping, URL percent encoding and HTML entities are different syntaxes. This tool performs only JSON string escaping and restoration; it does not convert URLs or process HTML entities. A JSON string is also not an HTML script-embedding sanitizer. Use the correct escaping rules for the destination context.

Input, output and limits

Text-to-JSON accepts up to 10,000 UTF-16 code units and returns one complete quoted string. JSON-to-text accepts up to 60,002 UTF-16 units including surrounding whitespace, and its decoded text is limited to 10,000 units. One input per run; no file upload, batch processing, daily quota, login, registration or saved history. All processing stays in your browser.

Restoration requires one complete double-quoted JSON string; objects, arrays, numbers, booleans and null are not accepted. Raw controls inside that string must be escaped. Empty text serializes to two quotes, and that quoted empty string restores to empty text. Invalid syntax reports an error and clears the previous result. Copy output copies the generated string itself, preserving parsed carriage returns, line feeds, tabs and other controls. Text boxes display carriage returns as line breaks; their visible appearance does not distinguish every control character. The browser normalizes pasted textarea line endings, so use explicit JSON escapes when exact carriage returns matter. ASCII-only affects escaping only.

Related byte and character tools

Hex Decoder interprets byte representations. Unicode Converter compares text, code points and UTF-8 bytes. This page formats JSON strings; it does not reinterpret a pasted hexadecimal number as a character. See RFC 8259 string syntax for the JSON escape rules.

Related representation walkthrough

This existing video discusses character-art representations, not JSON syntax. Loading the player connects to YouTube and shares connection information such as your IP address and playback requests.

Watch the existing representation walkthrough