How to use the json escape
- Type or paste the text you want to put inside a JSON string.
- Leave Include surrounding double quotes on if you want a complete JSON string value, or turn it off to get only the escaped content.
- Turn on Escape non-ASCII as \uXXXX if the target system only accepts ASCII, such as a legacy log pipeline.
- Copy the escaped result and paste it into your JSON document, API payload or source code.
What JSON escaping does
A JSON string is wrapped in double quotes, so a few characters cannot appear in it as they are. The json escape step replaces each of those characters with a short backslash sequence, which the JSON parser turns back into the original character when it reads the value. Without escaping, a single stray double quote ends the string early and the whole document becomes invalid.
RFC 8259 requires escaping for three groups of characters: the double quote, the backslash, and every control character from U+0000 to U+001F. This tool follows that rule exactly and nothing more, so the output is identical to what JSON.stringify produces for the same text.
Escape sequences used by the tool
Characters with a short form use it. The rest of the control characters are written as a six character \u escape with four lowercase hexadecimal digits.
| Character | Escaped as |
|---|---|
| Double quote | \" |
| Backslash | \\ |
| Newline (U+000A) | \n |
| Carriage return (U+000D) | \r |
| Tab (U+0009) | \t |
| Backspace (U+0008) | \b |
| Form feed (U+000C) | \f |
| Other control characters | \u0000 to \u001f |
The forward slash is not escaped, because JSON does not require it. Characters above U+001F, including accented letters, Chinese characters and emoji, pass through unchanged unless you turn on the Unicode option.
Escaping non-ASCII characters
With Escape non-ASCII as \uXXXX enabled, every character above U+007F is written as a \u escape. Characters outside the Basic Multilingual Plane, such as emoji, are written as a surrogate pair of two escapes, for example the globe emoji becomes \ud83c\udf0d. This is exactly how JSON represents those characters, so any compliant parser reads them back correctly.
A lone surrogate half (a high or low surrogate with no partner) cannot be shown as text. The tool always escapes it as \udXXXX, with or without the Unicode option, so the output stays valid and the character is not replaced by a question mark.
Use the Unicode option when the text has to cross a system that mangles non-ASCII bytes. Leave it off when the receiving side handles UTF-8, because the output is shorter and easier to read.
Common places you need to escape JSON
A json escape pass is needed whenever you build a JSON request body by hand. A shell script or a test fixture is the classic case, because a name such as O"Brien or a Windows path such as C:\Users\name breaks the payload unless it is escaped first. Multi-line text such as log messages, SQL queries, Markdown and stack traces also needs its newlines turned into \n before it can sit on one JSON line.
The same step helps when you embed JSON inside another JSON string, for example a webhook field that carries a serialized payload. Escape the inner document once for each level of embedding. To go the other way and read an escaped value, use the JSON unescape tool, and to check or reformat the finished document use the JSON formatter.
Limits and behaviour to know
This json escape tool processes text as typed, so it does not trim whitespace and does not change line endings: a pasted Windows line ending becomes \r\n. Empty input gives an empty string, which is "" when quotes are included.
It escapes a string, not a whole JSON document. If you paste a complete JSON object, the quotes inside it are escaped too and the result is a string that contains JSON. Percent encoding for URLs is a different job, handled by the URL encoder, and binary data is better carried with Base64. Everything runs in your browser and the text is never sent anywhere.
Worked examples
| Example | Input | Result |
|---|---|---|
| Simple sentence with quotes | Input text: He said "hello"; Include surrounding double quotes: yes; Escape non-ASCII as \uXXXX: no | "He said \"hello\"" |
| Text with newlines and tabs | Input text: Line 1 / Line 2 Tabbed; Include surrounding double quotes: yes; Escape non-ASCII as \uXXXX: no | "Line 1\nLine 2\tTabbed" |
| Unicode emoji escaped | Input text: Hello 🌍; Include surrounding double quotes: yes; Escape non-ASCII as \uXXXX: yes | "Hello \ud83c\udf0d" |
| Windows file path | Input text: C:\Users\name\file.txt; Include surrounding double quotes: no; Escape non-ASCII as \uXXXX: no | C:\\Users\\name\\file.txt |
FAQ
Which characters must be escaped in a JSON string?
The double quote, the backslash and every control character from U+0000 to U+001F. Everything else, including the forward slash and non-ASCII letters, may appear unescaped.
Is the json escape result the same as JSON.stringify?
Yes for the escaping itself. The tool uses the same short forms (\n, \t, \r, \b, \f) and the same six character form for other control characters. It also escapes lone surrogates, as modern JSON.stringify does.
Do I need the surrounding double quotes?
Keep Include surrounding double quotes on when you want a complete JSON string value to paste into a document. Turn it off when you are building a larger string yourself or pasting between quotes that already exist.
When should I turn on Unicode escaping?
Only when the destination cannot handle UTF-8, such as an ASCII-only log system. Emoji become surrogate pairs like \ud83c\udf0d, which every JSON parser decodes back to the same character.
Why is the forward slash not escaped?
JSON allows \/ but does not require it. Escaping it is only useful when JSON is embedded inside an HTML script tag, so the tool leaves it as it is.
Is my text uploaded anywhere?
No. The escaping runs in your browser and nothing is sent to a server.