About String Escape
Escape special characters (<code>\n</code>, <code>\t</code>, <code>\"</code>, <code>\\</code>) for embedding a string into source code. Pick the target language — JavaScript, Python, Java, C, Go, JSON, SQL, Bash, regex. Each has its own rules; the tool applies the right ones.
When this matters
You have text that needs to live inside a source file as a string literal. Quotes, newlines, backslashes need handling. Each language has its own rules — and getting them wrong means a syntax error or, worse, a silent bug that misinterprets your data.
Language differences
| Language | String quote | Newline escape | Notes |
|---|---|---|---|
| JavaScript | ', ", `` | \n | Template literals allow real newlines |
| Python | ', ", ''', """ | \n | Triple-quoted preserves newlines |
| Java | ", """ (text block) | \n | Text blocks added in Java 15 |
| C / C++ | " | \n | Concat with adjacent strings |
| Go | ", ` | \n | Backtick is raw |
| JSON | " | \n | Strict — no comments, no trailing comma |
| SQL | ' | none usually | Doubled single quote '' |
| Bash | ', " | varies | Different rules in single-quoted strings |
| Regex | n/a | n/a | Escape metacharacters |
Common workflows
Embed a multiline JSON in a Bash script. Pick Bash target, escape, paste into single-quoted assignment.
Build a regex from a literal string. Pick regex target, escape; the result is the literal pattern.
Move a string between languages. Decode from source A, encode to source B. The tool’s bi-directional escape handles the round-trip.
Fix an embedded SQL injection-prone literal. Use parameterized queries instead — but if you must escape, the SQL target handles doubled quotes correctly.
Frequently asked questions
Which characters get escaped?
" (or '), \\, newline, tab. Some add control chars, some add unicode. Pick the language for the right rules.Single-quote or double?
Round-trip?
What about regex escape?
.*+?[](){}|^$\). Pick the regex target to escape those for use as a literal pattern.HTML / XML?
Will it preserve emoji?
\u escapes.Related tools
Last updated: 2025-01-15