General dev

JSON & JavaScript String Escaper

Runs locally

Use JSON & JavaScript String Escaper

What it does

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

It runs entirely in your browser: nothing you enter is uploaded.

Example

Quotes, tab and line break

Input
Line 1
She said "hi"	C:\temp
Output (captured 2026-10-20)
"Line 1\nShe said \"hi\"\tC:\\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.