Code string escaper
Turn pasted text into a string literal for C, Python, SQL, shell and 16 other languages — and back.
Code string escaper
Paste text and this tool turns it into a valid string literal for the language you pick — C, C++, C#, Java, JavaScript, TypeScript, Python, Go, Rust, PHP, Ruby, Swift, Kotlin, SQL, Shell, PowerShell, YAML, JSON, XML or CSV — or runs it in reverse to turn an escaped literal back into plain text. Every language escapes quotes, backslashes and newlines a little differently: syntax that's valid PHP single-quoted breaks as Python, and a bash double-quoted string doesn't behave like a PowerShell one with the same punctuation.
Pick a quote style to match what you're pasting into — single, double or backtick, where the language supports it; an unsupported combination, like a backtick string in C, falls back to the language's own default instead of producing invalid code. "Wrap result in quotes" adds or omits the surrounding quote characters. "Escape non-ASCII as \u sequences" turns accented letters and emoji into \uXXXX escapes for strict ASCII output; left off, they stay literal UTF-8. "Keep literal tabs" leaves tab characters as-is instead of writing the tab escape.
"Use multi-line literal instead of \n" switches multi-line text to the language's native multi-line form where one exists — a Python triple-quoted string, a JavaScript template literal, a PHP or Ruby heredoc, a bash quoted heredoc, a PowerShell here-string, or a YAML block scalar — so the result reads with real line breaks instead of a wall of \n. Languages without one (C, C++, C#, Go, Kotlin, JSON, XML, CSV) fall back to \n escapes.
Everything runs locally in your browser. The snippet you paste — a config value, a log line, user input you're hardening for a query — never leaves your device. Copy the result, download it as a .txt file, or send it into another tool to keep working.