Toolstia / JSON string escape and unescape

JSON string escape and unescape

Prompts and other multi-line text need escaping before they can go inside a JSON value. Paste your text to escape quotes, backslashes and line breaks, or paste an escaped string to see the original.

Escaping adds backslashes before quotes and slashes and turns line breaks into \n, so the text is safe inside a JSON string, such as a prompt in an API request.

How it works

  1. Choose escape or unescape.
  2. Paste your text.
  3. Copy the result.

What gets escaped

Double quotes, backslashes, tabs and line breaks become \", \\, \t and \n. Other control characters become \u codes.

Non-English characters

They are left as they are by default. Switch on the option to escape them as \uXXXX codes for systems that need plain ASCII.

Quotes

Choose whether the result is wrapped in double quotes so it can be pasted as a complete JSON value.

Unescape errors

If the text has a stray backslash, an unescaped quote or a real line break, the tool tells you it is not a valid JSON string.

Questions

Why not just use a JSON formatter?

A formatter lays out whole JSON documents. This tool prepares or reads a single string value inside one.

Is the result valid for APIs?

Yes. It follows the JSON standard, so it works in request bodies.

Is my text uploaded?

Everything happens in your browser, and nothing you paste is sent anywhere.