String Literal Escaper (Java, C, C#, Python, Go, Rust, JSON, SQL, Bash)
Wraps raw text into a correct string literal for the language you pick: quotes, backslashes, newlines, control characters and, if you want, non-ASCII characters become the escapes that language accepts.
Use the tool
Why this tool exists
Pasting a Windows path, a JSON snippet or a multi-line message into source code means escaping quotes and backslashes by hand. Each language has its own rules: Java has no \x escape, C reads \x greedily, SQL doubles single quotes, and Bash single quotes cannot hold an apostrophe.
The tool applies those rules and can also undo common backslash escapes. For C it writes control characters as three-digit octal, which cannot run into the next character. The result was checked by evaluating it in Python, JavaScript, JSON and Bash. The other languages follow their documented escape rules.
How to use it
- Paste the raw text.
- Pick the language and direction.
- Tick non-ASCII escaping if the source file must stay ASCII.
- Copy the literal.
Frequently asked questions
Why are control characters written differently per language?
Java and C# accept \uXXXX, C accepts octal, Python and Go accept \xHH. The tool uses what each language allows.
What does unescape do?
It reads backslash escapes (n, t, r, b, f, v, a, xHH, uXXXX, u{...}, octal) after removing surrounding quotes.
Is the Java output safe for \u processing?
Yes. It uses \n and \r for line breaks, since a raw \u000a would break a Java source file.
Does it cover raw strings or template literals?
Only the usual quoted form. JavaScript can use backticks if you choose that quote style yourself.