EN
My tools

String Escape / Unescape (JavaScript, Java, C#, Python, Go, PHP, Bash)

Escape or unescape string literals for JavaScript, Java, C#, C/C++, Python, Go, PHP, Bash, PowerShell, regex and CSV, with \n, \uXXXX, \x and octal.

Direction
Escape only. Keeps source files pure ASCII.
Escape only. When unescaping, surrounding quotes and prefixes (@, r, b, $) are detected and removed automatically.
Result
Line 1: \"quotes\" and 'apostrophes'\nLine 2:\tC:\\Users\\Ada — café 😀
Characters before
64
Characters after
70

Line breaks became \n, so the literal is one line.

My tools →
Advertisement

Every language has its own rules for writing special characters inside a string: JavaScript and Java use \n and \uXXXX, C# reads up to four hex digits after \x, C reads every hex digit, Go treats \x as a byte, PHP only escapes in double quotes, and shells need completely different tricks. This tool escapes plain text into a correct literal for the language you pick, and unescapes a literal back into the text it stands for, following each language's own grammar.

How to use this tool

  1. Paste the text, or the string literal you want to decode.
  2. Choose Escape or Unescape.
  3. Pick the language and quote style, such as Python '…' or C# verbatim @"…".
  4. For escaping, optionally turn non-ASCII characters into escapes and add the quotes.
  5. Copy the result.

Formula

escape: \ → \\ · quote → \" · line break → \n · tab → \t · control characters → \x, \u or octal per language

Unescaping follows each grammar: JavaScript accepts \x, \u, \u{…}, line continuations and legacy octal; Java octal up to \377 and \uXXXX; C# \x with 1–4 digits and \U; C and Go octal/hex escapes are bytes decoded as UTF-8; Python keeps the backslash of unknown escapes; PHP and Bash keep unknown escapes as written. Escapes that a language rejects (Java \q, Go \') are reported with their line and column. When unescaping, surrounding quotes and prefixes such as @, r or $ are removed automatically.

Example

The sample has quotes, a line break, a tab and Windows backslashes. As a JavaScript "…" literal it becomes Line 1: \"quotes\" and 'apostrophes'\nLine 2:\tC:\\Users\\Ada — café 😀 — the apostrophes stay because the string uses double quotes. Unescaping the C# text \x41BC gives the single character 䆼 (U+41BC), not "ABC", because C# reads four hex digits.

Frequently asked questions

Why does Java never get \u000A?

Java converts \u escapes before it reads the program, so \u000A becomes a real line break inside the string and the code no longer compiles. This tool writes \n and \r instead.

How do I put a single quote inside a shell '…' string?

Single quotes cannot contain one, so you close the string, add an escaped quote and reopen it: it's becomes 'it'\''s'. Bash also offers $'…' strings, where \' works.

Are unknown escapes an error?

It depends on the language. Java, C# and Go reject them (you get an error with the position); JavaScript drops the backslash; Python, PHP and Bash keep the backslash; C compilers warn and use the character.

Is my text sent anywhere?

No. Escaping and unescaping run in your browser.

Sources

Last updated:

Cite or embed this tool
APA

kakaoCalc. (2026, November 8). String Escape / Unescape (JavaScript, Java, C#, Python, Go, PHP, Bash). https://kakao.mobile/tools/string-escape-tool/

MLA

“String Escape / Unescape (JavaScript, Java, C#, Python, Go, PHP, Bash).” kakaoCalc, 8 Nov. 2026, kakao.mobile/tools/string-escape-tool/.

Paste this code into your page. The widget runs in your visitors' browsers, shows no ads and keeps a link back to this page. Embedding terms

Advertisement