ToolBark
Developer

String Escape and Unescape

Escape and unescape strings for JSON, JavaScript, and Unicode instantly

57 in64 out+7 chars

Quick Reference

\nNewline (LF)
\rCarriage return (CR)
\tHorizontal tab
\"Double quote
\'Single quote (JS)
\\Backslash
\bBackspace
\fForm feed
\uXXXXUnicode code point
About

String Escape and Unescape converts raw text into safely escaped sequences for JSON, JavaScript, or Unicode — and back again. Handle double quotes, single quotes, backslashes, newlines, tabs, and full \uXXXX Unicode code points with one click. Ideal for debugging API payloads, writing config files, or sanitizing strings before embedding them in code.

FAQ
What is the difference between JSON escape and JavaScript escape?+

JSON only permits double-quoted strings, so it escapes double quotes and common control characters (\n, \t, \r, etc.) plus \uXXXX unicode. JavaScript goes further: it also escapes single quotes, backticks, null bytes (\0), hex sequences (\xNN), and octal literals — useful when building JS string literals or template literals.

Why does my escaped string look longer than the original?+

Every special character is replaced by a multi-character escape sequence — for example a single newline (1 char) becomes \n (2 chars). The output character count shown after conversion reflects this expected growth.

What does 'Non-ASCII only' mean in Unicode mode?+

When checked, only characters with a code point above 127 (accented letters, symbols, emoji surrogates) are replaced with \uXXXX sequences. Plain ASCII letters, digits, and punctuation are left as-is, keeping the output readable. Uncheck it to encode every single character.

Can I round-trip (escape then unescape) without losing data?+

Yes. Use the Swap button to move the escaped output back to the input, then switch direction to unescape. The tool reconstructs the exact original string, including all control characters and special symbols.

Related tools