What this tool does
Turns multi-line text into a JSON string literal, or converts one back. Use it when newlines and quotes need escaping.
How to use it
- Paste the text.
- Choose the direction: encode to escape, decode to restore.
- Run it and copy the result.
Worked example
Encoding a two-line text gives a single-line string with the newline written as \n. Decoding restores the two lines.
Frequently asked questions
- Why is escaping needed?
- A JSON string cannot contain raw newlines or quotes. Escaping is required to embed multi-line text in a config file or an API request body.
- My backslashes doubled.
- That is correct — a backslash is itself escaped, so it appears as \\. Decoding returns it to one.
What this tool does not cover
Input is processed in your browser. It handles a single string and does not validate a whole JSON document.