JSON Escape and Unescape
Escape and unescape JSON string content safely.
Escape raw text for use inside JavaScript string literals, or decode JavaScript escape sequences back to plain text without eval.
Choose whether the output is intended for a double-quoted string, single-quoted string, or template literal.
Your text is processed in this browser and is not submitted to UnicodeNow.
This tool works with JavaScript string content. It does not parse complete JavaScript programs, evaluate expressions, decode variables, execute template interpolation, or validate arbitrary source snippets. For strict JSON string escaping, use JSON Escape and Unescape.
Operation
Normalization changes the Unicode sequence and is separate from JavaScript escaping.
NFKC and NFKD may replace compatibility characters and remove distinctions that matter in some workflows.
Input is raw string content, not a complete JavaScript source snippet.
Output is plain text and is never executed or rendered as HTML.
Run the tool to inspect generated or parsed escape sequences.
| Input | Code point | Output | Reason or status |
|---|
This tool converts raw text into JavaScript string escape notation, and converts JavaScript escape notation back into decoded text. It is designed for string content: the characters that would appear inside quotes or backticks. It does not execute JavaScript, parse complete programs, evaluate variables, combine string concatenations or run template expressions.
| Character | Escape |
|---|---|
| Line feed | \n |
| Tab | \t |
| Carriage return | \r |
| Backslash | \\ |
| Double quote | \" |
| Single quote | \' |
| Backspace | \b |
| Form feed | \f |
| Vertical tab | \v |
| Null | \0 |
In a double-quoted string, the double quote, backslash and control characters need escaping. A single quote can remain literal. With delimiters disabled, the output is only the escaped content. With delimiters enabled, the output is wrapped in quotation marks.
Single-quoted strings escape the single quote, backslash and control characters. Double quotes can remain literal. Choose this context when the escaped content will be placed between apostrophes in JavaScript source.
Template literals use backticks and support ${...} interpolation. This tool escapes backticks, backslashes and interpolation starts so raw input such as Hello ${name} becomes Hello \${name}. Ordinary dollar signs are preserved.
JavaScript supports \u00E9 for one UTF-16 code unit, \u{1F600} for one Unicode code point, and legacy surrogate-pair notation such as \uD83D\uDE00 for emoji. The tool validates surrogate pairs when unescaping and can generate either legacy or code-point escape style when escaping non-ASCII text.
JavaScript string syntax supports forms that JSON does not, including single-quoted strings, template literals, \v, \xHH and \u{...}. For strict JSON string escaping, use JSON Escape and Unescape.
Unescape mode uses a dedicated parser for supported escape sequences. It never calls eval(), never creates script elements and never executes input. The parser decodes one syntax layer only, so \\n becomes a literal backslash plus n rather than being recursively decoded into a line break.
Trailing backslashes, malformed \x escapes, incomplete \u escapes, out-of-range code points and isolated surrogate halves are reported as errors. Malformed escape syntax is not silently preserved in strict mode.
JavaScript string escaping does not make text safe for HTML, SQL, URLs, shell commands, CSS, template systems or DOM insertion. Use the correct escaping or encoding for the final context.
Normalization is separate from escaping and is off by default. If enabled in Escape mode, normalization is applied before escape sequences are generated and may change the Unicode code-point sequence.
Choose Escape when you have raw text and need JavaScript string content. Select the string context first: double-quoted, single-quoted, template literal or raw escape notation. Then decide whether the output should include surrounding delimiters. The default keeps delimiters off, which is useful when you only need the content that will be placed inside an existing string literal.
Choose Unescape when you have escape notation such as \n, \x41, \u00E9 or \u{1F600}. The parser decodes one layer of supported string escapes and reports malformed syntax instead of guessing. If you are working with JSON, use the JSON tool because JSON does not allow several JavaScript-specific escape forms.
Use the Unicode character handling selector when you need non-ASCII characters preserved, converted to legacy UTF-16 escapes, or represented with modern code-point escapes. Use output as input only when you intentionally want to run another pass with the current settings.
This tool runs in your browser. Your input is not submitted to UnicodeNow, inserted into URLs, saved to localStorage or sessionStorage, or sent through analytics by this page.
\uXXXX.Input text:
Line 1
Line 2 "UnicodeNow"
C:\Tools
😀
Output for a double-quoted JavaScript string with code-point escapes:
Line 1\nLine 2 \"UnicodeNow\"\nC:\\Tools\n\u{1F600}
The output is escaped string content. Enable “Include surrounding delimiters” to generate a complete quoted string literal.
Template-literal input:
Hello ${name}
Output:
Hello \${name}
It replaces special characters with escape sequences suitable for JavaScript string syntax.
No. Escaping represents characters within source syntax; encoding converts data between representations such as UTF-8 or Base64.
Use \" for double-quoted strings and \' for single-quoted strings.
Use \\.
It represents a line-feed character.
\uXXXX represents one UTF-16 code unit, while \u{...} represents one Unicode code point.
Emoji can use a code-point escape such as \u{1F600} or a UTF-16 surrogate pair such as \uD83D\uDE00.
Surrogate pairs are two UTF-16 code units used to represent one supplementary Unicode code point.
Yes. This tool parses supported escape syntax directly and does not execute JavaScript.
No. JSON uses a stricter subset of string escape syntax.
They use backticks, allow literal line breaks, and support ${...} interpolation.
No. It treats input as string content or escape notation only.
No. Escaping for JavaScript strings does not make text safe for HTML, SQL, URLs, shell commands or DOM insertion.
No. This tool runs in your browser and does not submit input to UnicodeNow.
Escape and unescape JSON string content safely.
Convert text to and from Unicode escape sequences and numeric entities.
Convert Python string escapes without executing Python code.
Escape and unescape PHP-style single and double quoted strings.
Encode and decode HTML named, decimal and hexadecimal entities.
Escape and decode XML entities and numeric character references.
Encode and decode URL components, full URLs and form-style strings.
Convert text into U+XXXX Unicode code point notation.
Convert U+XXXX, 0x, and escape-style code points back to text.
Unicode defines characters and code points. UTF-8 encodes those code points as bytes for files, databases, web pages, APIs and network messages.
Learn what Unicode code points are, how U+ notation works, and how code points differ from glyphs, bytes, code units and visible characters.
Learn NFC, NFD, NFKC and NFKD, canonical and compatibility equivalence, and safe normalization for comparison, search and identifiers.
Learn how Unicode escape syntax works across JavaScript, JSON, Python, PHP, Java, HTML, CSS and URLs.