# JSON & JavaScript String Escaper

URL: https://phishdestroy.io/developer-tools/string-escaper
Category: General dev
Where it runs: Runs locally (nothing you enter is uploaded)

Escape text for use inside a JSON or JavaScript string literal, or decode a quoted JSON string back to plain text.

## Example input

Quotes, tab and line break

```
Line 1
She said "hi"	C:\temp
```

JSON escape gives "Line 1\nShe said \"hi\"\tC:\\temp" including the outer quotes; JS escape gives the same text without the outer quotes.

## FAQ

### What is the difference between JSON escape and JS escape?

JSON escape is JSON.stringify: it adds the outer double quotes and escapes quotes, backslashes and every control character. JS escape only escapes backslashes, single and double quotes, \n, \r and \t, and adds no quotes.

### What does it not handle?

There is no SQL escaping; use parameterised queries instead. JS escape leaves other control characters and a closing script tag unchanged, so do not use it to put untrusted text into a script element, and JSON unescape expects a quoted string (an object comes out as [object Object]).

### Is my text uploaded?

No. Escaping uses JSON.stringify, JSON.parse and simple replacements in your browser; nothing is sent anywhere.

## Related tools

- [HTML Escape / Unescape](https://phishdestroy.io/developer-tools/html-entity-encoder)
- [JSON Formatter](https://phishdestroy.io/developer-tools/json-formatter)
- [URL Encoder / Decoder](https://phishdestroy.io/developer-tools/url-encoder-decoder)
- [Base64 Encoder / Decoder](https://phishdestroy.io/developer-tools/base64-encoder-decoder)
- [Unicode Inspector](https://phishdestroy.io/developer-tools/unicode-inspector)

All tools: https://phishdestroy.io/developer-tools
