String Escaper

Escape or unescape text for JSON and JavaScript string literals, with quote, control-character and Unicode handling.

Escape options

Input: 0 chars · Result: 0 chars

No uploads. Your files stay on your device.

Free forever, no sign-up, no cookies. Buy me a coffee

How it works

Paste text on the left and the escaped string literal appears on the right instantly. Escaping turns quotes into \" or \', tabs into \t, line breaks into \n, backslashes into \\ and any other control character into a \u00XX code — exactly what you need to drop a value safely inside a JSON file or a JavaScript string. Pick the target syntax to match where the string is going: JSON is strict (no \v, \0 or \x escapes), while the JavaScript modes also escape the right quote character and, for template literals, the backtick and the dollar-brace opener. The options above the boxes wrap the result in quotes, turn every non-ASCII character (accents, emoji, dashes) into a \uXXXX code, and escape forward slashes as \/ for embedding in HTML.

Switch the direction to Unescape and the tool goes the other way: it strips the surrounding quotes if you pasted them and decodes \n, \t, \r, \b, \f, \v, \0, \xNN and \uXXXX (including code-point escapes) back into real characters. If an escape sequence is malformed you get a plain-English message with the position instead of a silent wrong answer. Everything runs in your browser with vanilla JavaScript — nothing is uploaded, so it is safe for tokens, keys and customer data.

Frequently asked questions

How do I escape double quotes in JSON?

Paste your text, keep the direction on Escape and the target on "JSON string": every double quote becomes \" and every backslash becomes \\, so the result can be pasted straight between the quotes of a JSON value. Tick "Wrap the result in quotes" if you want the surrounding quotes added for you.

How do I escape a newline in a JavaScript string?

Line breaks cannot appear raw inside a normal JavaScript string, so the escaper converts them to \n and carriage returns to \r. Tabs become \t and any other control character becomes a \u00XX code. Pick the JavaScript target that matches your quote style so the right quote character — or the backtick and dollar-brace opener in a template literal — is escaped too.

Can I unescape a JSON or JavaScript string back to plain text?

Yes. Switch the direction to Unescape and paste the literal, with or without its surrounding quotes. It decodes \n, \t, \r, \b, \f, \v, \0, \xNN and \uXXXX escapes (including code-point escapes) back into real characters, and tells you the exact position if an escape sequence is malformed.

Report a bug