Escaping is always about context
There is no universal “escape this string”, escaping only makes sense relative to where the string is going. The same character is dangerous in one context and harmless in another:
| Context | What needs escaping | Escape form |
|---|---|---|
| JSON | " \ newline | \" \\ \n |
| HTML | < > & | < > & |
| URL | reserved + spaces | %20, %26, … |
| RegEx | . * + ? ( ) [ ] … | backslash-prefixed |
| SQL | ' | '' |
| Shell | everything (quote it) | single-quote wrap |
This tool covers 12 contexts in one place so you can see, side by side, how the same input is escaped completely differently for JavaScript versus SQL versus a shell argument, which is the fastest way to build intuition for why context matters.
The double-encoding trap
The most common escaping bug is applying it twice. A value that’s escaped once (& → &) and then escaped again becomes &amp;, which renders literally as & on the page. This happens constantly when manual escaping is layered on top of a framework that already auto-escapes. The rule: escape exactly once, at the boundary where the data enters its target context. If you see &amp; or %2520 in output, you’ve encoded one layer too many, paste it here and unescape once to confirm how many layers are stacked.
Use it to debug, not to secure
Reach for this tool when you need to:
- Prepare test data: craft a payload with exactly the escaping a parser expects.
- Debug a parser error: see whether a stray quote or backslash is breaking your JSON/CSV.
- Compare contexts: understand why a string that’s valid in JavaScript breaks in JSON (JSON allows far fewer escape sequences).
- Reverse an operation: the Swap button feeds output back as input and flips direction, so you can verify a round-trip.
Everything runs in your browser, so even sensitive test strings stay local. Just remember the boundary: this is a learning and debugging instrument; your application’s actual injection defense belongs in parameterized queries and framework-level escaping.