Practical guide
How to use JSON String Escaper
Turn multiline text into a quoted JSON string for fixtures, configuration values, and request examples. The reverse operation reads a complete JSON string literal and restores its text, including newlines, quotes, backslashes, and Unicode. This tool handles one string rather than repairing or formatting an entire JSON document.
Step by step
- Select Text → JSON string to escape plain text, or JSON string → Text to decode a string literal.
- Paste the input. Decoding requires the surrounding double quotes; encoding accepts empty text as a valid empty string.
- Select Convert, review the result, and copy it into the appropriate string field in your document.
Example
Hello "77" followed by a newline"Hello \"77\"\n"How it works
Encoding uses JSON.stringify on the input string. Decoding uses JSON.parse and then verifies that the parsed value is actually a string. Objects, arrays, numbers, booleans, and null are rejected even though they may be valid JSON. No code is evaluated.
Important limitations
- JSON escaping does not make text safe for HTML, inline script tags, SQL, or shell commands. Use the escaping rules of the destination context.
- A single operation accepts up to one million UTF-16 code units. Escaped newlines become actual line breaks in decoded output.
Real workflows
When this tool is useful
Multiline fixtures
Represent a small multiline message as a single JSON string in a test fixture while retaining its line breaks after parsing.
Log inspection
Decode a quoted string copied from a JSON log so embedded quotes and line breaks become readable again.
Review the result
What to check before using the output
Check whether the destination expects a full quoted string or only its contents. In a JSON document, use the complete encoded result once; encoding it a second time produces literal backslashes rather than the intended text.
- Choose the intended conversion direction.
- Keep outer quotes when inserting a JSON value.
- Avoid using JSON escaping in a different syntax context.
Choose the right method
When another tool is better
Use JSON Fix to repair a document, HTML Entity Encoder for markup text, or Base64 for a transport representation. None of these transformations substitutes for encryption.
Privacy and browser behavior
Strings are transformed only in the active browser tab and are not saved to local storage. Clear the text before sharing your screen if it contains request payloads or private messages.
Frequently asked questions
Will Chinese text and emoji survive?
Yes. JSON supports Unicode strings, and ordinary non-ASCII characters remain readable. Control characters, quotes, and backslashes receive the escaping required by JSON.
Why is my object rejected?
Unescape expects a single JSON string such as "hello", not an object such as {"message":"hello"}. Use JSON Fix for complete documents that need repair or formatting.