Processed on your device

JSON string escape and unescape

Escape text into one JSON string in double quotes, or unescape a JSON string back to plain text.

1

Make it yours

To unescape, replace the example with a JSON string in double quotes, such as "Hello\nworld".
No uploads

Ready when you are. Nothing runs until you choose.

2

Your result

Your result will appear here.

About JSON string escape and unescape

Use this to move text in and out of JSON string values. Escape text into a JSON string wraps a message, a block of HTML or any other text in double quotes. Quotes, backslashes, tabs and line breaks inside it are escaped, so the result can be pasted after a key. Unescape a JSON string into text does the reverse: a string copied from JSON, a log or source code, full of \n and \" sequences, becomes readable text.

How it works

To escape, StillKit passes your text to JSON.stringify, built into your browser. It writes \" for a double quote, \\ for a backslash, \n for a line break and \t for a tab, and a code such as \f or \u0001 for other control characters, then wraps the whole in double quotes. To unescape, it parses the input as strict JSON, which turns each escape back into its character, and accepts the result only if it is a single string. That string is shown without its quotes.

Tips

  • Escaping keeps accented letters and emoji as they are, which UTF-8 JSON allows. Unescaping turns codes such as \u00e9 and pairs like \ud83d\udc4b into the real characters, é and an emoji.
  • Spaces at the start and end of the text stay inside the quotes, as the example shows, so trim the text first if you do not want them.
  • To unescape, paste the string with its surrounding double quotes. Hello on its own, or 'Hello' in single quotes, is rejected, and so is a number or any other JSON value.
  • A raw line break inside the quotes is not allowed in JSON, so a string copied across several lines fails until each break is written as \n.
  • Only 1 string is accepted at a time. For a whole JSON document, use JSON formatter.
GOOD TO KNOW

Limits

Maximum 1 MB of input. Escaping accepts any text. Unescaping accepts exactly one JSON string in double quotes; nothing in it is evaluated, and the result is shown as plain text.

How tools run on your device →
EXAMPLE

A worked example

Example input

Text or JSON string:   First useful idea.  

Second useful idea.
  First useful idea.  
Direction: Escape text into a JSON string

Example result

"  First useful idea.  \n\nSecond useful idea.\n  First useful idea.  "

Questions and answers

Which direction do I need?

Escape when you are writing text into JSON, such as a message for a request body or a configuration value. Unescape when you are reading a string copied out of JSON, a log or source code and want the plain text.

How do I undo text that was escaped twice?

Run Unescape once for each layer. A string such as "\"Hello\\nworld\"" first gives "Hello\nworld" with its quotes, and a second run gives the 2 lines of text.

Find your next shortcut

Search loads only when needed. Your search stays on your device.

Browse all categories and sections →