String Escaper
Escape and unescape strings for JavaScript, JSON, and shell contexts with a live preview.
About String Escaper
Embedding a piece of text into source code, a JSON payload, or a shell command is easy to get subtly wrong, because quotes, backslashes, and control characters mean something special in each context. This tool escapes (and unescapes) strings for JavaScript, JSON, and shell, with a live preview as you type.
Choose the target context and the tool handles exactly the characters that matter there: JavaScript and JSON escape double quotes and control characters, while shell escaping handles spaces, quotes, and glob characters. The preview updates on every keystroke, and switching to unescape mode reverses any of the three styles.
Developers embedding user input into code, building JSON payloads by hand, or scripting commands with dynamic arguments use it constantly. QA engineers also find it handy for building test strings that include special characters without fighting the terminal.
How to Use
- Paste the string to escape or unescape.
- Pick the target context: JS, JSON, or shell.
- Copy the escaped (or unescaped) result.
Example
He said "hi" and it's fine. He said \"hi\" and it\'s fine.
Quotes and apostrophes gain backslash escapes so the string is safe inside a JavaScript string literal.
FAQ
What is string escaping for?
Making text safe to embed in source code, JSON payloads, or shell commands where quotes and backslashes have special meaning.
What's the difference between the contexts?
JavaScript and JSON escape double quotes and control characters; shell escaping targets spaces, quotes, and glob characters.
Can it unescape too?
Yes, switch to unescape mode to reverse any of the three escaping styles.
What about newlines and tabs in the input?
Control characters like newlines and tabs are converted to their escaped forms in the JavaScript and JSON modes, so the string literal stays on a single valid line.
Is the live preview safe for long strings?
Yes. The preview updates instantly even on long inputs, and large strings are handled without noticeable delay, so you can rely on it during bulk escaping work.