json ↔ string Converter

Run json ↔ string Converter using the supplied input and options.

Unicode text; preserve input unless the selected operation changes it.

Your workbenchInputs are not stored

Result

Enter your values and run the tool to see your result.

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

  1. Paste the text.
  2. Choose the direction: encode to escape, decode to restore.
  3. 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.

References