JSON Stringify Text
Dropping raw text straight into a JSON file usually breaks it. A single quotation mark ends the string early, a Windows file path full of backslashes turns into a mess of invalid escapes, and a multi-line message simply cannot span lines inside a JSON string at all. This tool takes any text and returns it as a properly escaped JSON string literal, quotes included, ready to paste into a config file, an API payload, or a test fixture.
Everything runs in your browser — nothing you paste is ever sent to a server, so it is safe to escape log output, error messages, or internal content here.
What does JSON stringify do to text?
It wraps your text in double quotes and escapes every character that would otherwise be
illegal or ambiguous inside a JSON string. Quotation marks become \",
backslashes become \\, and invisible characters such as line breaks and
tabs become the two-character sequences \n and \t. The result
is a single line of valid JSON that decodes back to exactly the text you started with.
The rules come straight from the JSON specification, and this tool matches JavaScript's
built-in
JSON.stringify()
exactly.
JSON string escape sequence reference
These are the substitutions applied to your text:
| Character | Escaped as | Notes |
|---|---|---|
Double quote " | \" | Would otherwise end the string early |
Backslash \ | \\ | Common in Windows paths and regex patterns |
| Line feed | \n | JSON strings cannot contain a real line break |
| Carriage return | \r | Appears in Windows-style CRLF text |
| Tab | \t | Preserved rather than converted to spaces |
| Backspace | \b | Rare, but valid in JSON |
| Form feed | \f | Rare, but valid in JSON |
| Other control characters | \u0007 | Anything below U+0020 without a shorthand escape |
Forward slash / | / (unchanged) | Escaping it is allowed but not required |
| Line/paragraph separator (U+2028, U+2029) | unchanged | Valid in JSON, but can break older JavaScript source |
Why are my accented letters and emoji not escaped?
Because they do not need to be. JSON is a Unicode format, so café,
中文, and 😀 are all perfectly valid inside a
JSON string exactly as they are. Writing them as \u00e9-style escapes is
also valid, and some tools do it, but it is optional — this tool matches the
behaviour of JavaScript's own JSON.stringify() and leaves them readable.
Why does my text show \r\n instead of just \n?
Your source text genuinely contains both characters. Text copied from Windows programs,
many email clients, and some log files uses a carriage return followed by a line feed
(CRLF) to end each line, while text from macOS and Linux typically uses a line feed
alone. The tool escapes faithfully rather than silently rewriting your line endings, so
\r\n in the output means \r\n was in the input.
Can I reverse this and unescape a JSON string?
Yes — use the JSON Unstringifier, the exact
inverse of this tool. It takes an escaped JSON string and returns the readable text or
JSON it was hiding, and it unwraps double-stringified payloads automatically. In code,
the equivalent is JSON.parse(). If you need to work with a whole JSON
document rather than a single string value, the
JSON Formatter will parse, validate, and pretty-print it.
Last reviewed: August 2026