String Escaper / Unescaper (JS, PHP, JSON, Bash)


String Escaping & Unescaping Across Languages

Copying multi-line SQL queries, JSON payloads, HTML snippets, or shell commands directly into source code almost always breaks syntax because of unescaped quotes, backslashes, tabs, and line breaks. This String Escaper converts raw text into safely escaped literals (and unescapes existing literals back into readable text) locally in your browser.

Supported Modes & Rules

  • JSON String: Uses JSON.stringify() rules - escapes double quotes (\"), backslashes (\\), newlines (\n), carriage returns (\r), tabs (\t), and control characters. Ideal for pasting raw text inside a JSON property value.
  • JavaScript / PHP Double-Quoted: Escapes backslashes, double quotes, single quotes, newlines, and tabs so you can drop multi-line strings cleanly into JS template/string literals or PHP double-quoted strings without syntax errors.
  • Bash / POSIX Single-Quoted: Wraps text in single quotes and replaces any embedded single quote with '\''. In POSIX shells, single-quoted strings preserve every character literally (including $VARS, backticks, and backslashes), making this the safest way to pass arbitrary text in shell scripts.

Common Use Cases & FAQ

  • Why does JSON escaping wrap or unwrap quotes? In JSON mode, escaping produces the inner escaped sequence (or full quoted literal) ready to place between quotes, while unescaping decodes \n, \t, \", and \uXXXX sequences back into real characters.
  • How do I turn an escaped log string back into readable multi-line text? Paste the log line containing literal \n and \" sequences, choose Unescape, and the tool restores real line breaks and quotes so you can read stack traces or SQL statements clearly.
  • Why is '\'' used in Bash escaping? Inside single quotes in Bash, nothing - not even a backslash - can escape another single quote. Therefore, closing the single quote ('), adding an escaped quote (\'), and reopening single quotes (') safely concatenates a literal apostrophe.
  • Does this handle Unicode and emojis? Yes. UTF-8 characters and emojis pass through intact in UTF-8 environments, and \uXXXX escapes in JSON unescape cleanly back to Unicode characters.
  • Is any text sent to the server? No. All escaping and unescaping run 100% locally in JavaScript.
Please read the privacy policy (agreement of the cookies usage, other websites embedded content, etc.). If you continue to use the site, we will assume that you agree with our privacy policy.
OkPrivacy Policy