String Escaper (Multi-language)
Escape or unescape a string literal for JSON, JavaScript, Java, C#, C, Python, SQL or POSIX shell — entirely on this device.
Adds the language's own quote delimiters around the escaped literal.
Escaping is not a substitute for parameterized queries — use placeholders in application code; this tool is for hand-written fixtures and migrations.
Press ? for shortcuts
Do it offline:$ jq -Rs . file.txt
How to use it
- Pick the target language — switching re-runs the conversion and resets nothing you typed.
- Paste text or a literal — \n-style sequences preselect Unescape, plain prose Escape, and input that reads both ways gets a banner offering each.
- The wrap toggle adds or omits the language's quote delimiters. Shell ignores it — the single-quote wrap is the escape mechanism itself.
- Copy or download the literal, or Share the tool state as a link — confirmed first whenever the input looks credential-shaped.
Every language dresses the same text differently: JSON writes a line break as \n, SQL doubles the quote, POSIX shell forbids escapes inside single quotes altogether. Pick one of eight literal grammars — JSON, JavaScript, Java, C#, C/C++, Python, SQL or shell — and turn raw text into a paste-ready literal, or a literal back into text, without the string leaving this device.
Examples
He said "hi"
line 2"He said \"hi\"\nline 2"Wrap on (the default) prints the delimiters: the inner quotes become \" , the real line break becomes the two characters \n, and JSON.parse gives back the original text exactly.
O'Brien'O''Brien'Standard SQL has exactly one escape inside a literal: the quote, written twice. No backslash is added — that is a MySQL dialect, not the standard.
it's'it'\''s'POSIX single quotes protect everything except the quote itself, so the apostrophe is spliced as '\'' — close, one escaped quote, reopen. The shell reads it as one word.
emoji 😀'emoji \U0001F600'😀 sits above U+FFFF, so Python spells it in the eight-digit \U form — Java or C# would emit the surrogate pair \uD83D\uDE00 instead. The wrapped form pastes straight into a .py file.
Every example on this page is executed against the same engine that powers the tool, on every build.
Gotchas worth knowing
Control characters never travel raw
All eight grammars convert every C0 control: the common ones take short forms — \t, \r, \n — and the rest are spelled numerically and counted by a chip, because an invisible \u0001 in a literal is almost always a paste accident.
Above U+FFFF the languages part ways
Emoji have no \uXXXX slot: JSON, JavaScript, Java and C# emit surrogate pairs, Python and C/C++ the eight-digit \UXXXXXXXX form, and a chip names the rewrite. Printable text below that — é to 漢 — passes through untouched in every language.
SQL mode doubles quotes — and that is all it does
'' is the whole of standard SQL string escaping. Escaping is not a substitute for parameterized queries — use placeholders in application code; this tool is for hand-written fixtures and migrations.
Shell output is one single-quote wrap, not backslash soup
Inside POSIX single quotes no escape exists — exactly why they are safe; the '\'' splice covers the one impossible character. Nesting a JSON body inside a shell command is a V2 feature; run the JSON pass here, then quote the result.
cmd and PowerShell are deliberately absent
Shell mode targets POSIX sh and its descendants; cmd escapes with ^ and expands %var%, PowerShell keeps backticks and $() live inside double quotes. Both wait for V2 as modes of their own.
The 1 MB cap refuses — it never trims
Error positions count across exactly what you pasted, so nothing is silently shortened. Past 1 MB the banner declines the whole input and names the CLI: jq -Rs . file.txt prints any file as a JSON literal.
Common errors
`\q` at position 9 is not a valid JSON escape- JSON has eight named escapes plus \uXXXX, and q begins none of them. Positions count characters from one, exactly as pasted; a Windows path in what you took for a JSON literal is the classic source.
`\u00` at position 9 is truncated — `\u` needs 4 hex digits- The input stops mid-escape, leaving nothing complete to decode — almost always a clipped copy: a log line cut at a column, a chat message truncated. Restore the missing tail rather than deleting the fragment.
Input is larger than the 1 MB limit for this tool. For bigger payloads use the CLI: jq -Rs . file.txt- A refusal, never a truncation: the page works on all of your input or none of it. jq -Rs . slurps a file and emits one wrapped JSON literal at any size.
FAQ
Does escaping user input make my SQL query safe?
No. Quote-doubling produces a valid literal; injection safety comes from parameterized queries, where values never enter the SQL text. Use SQL mode when hand-writing the statement anyway — seed data, fixtures, migrations.
Why does the shell result wrap everything in single quotes?
Double quotes leave $, backticks and backslashes alive, so a backslash strategy must chase every expansion rule. Single quotes are absolute: between them nothing has meaning — a rule that survives repasting.
Aren't JSON and JavaScript escapes the same thing?
Nearly. JSON is stricter — double quotes only, eight named escapes plus \uXXXX. JavaScript needs more: U+2028 and U+2029 are legal raw in JSON strings yet historically end a JavaScript line, so only JavaScript mode escapes them.
How do emoji come out in each language?
By code point. JSON, JavaScript, Java and C# have no notation above U+FFFF, so 😀 becomes the pair \uD83D\uDE00; Python and C/C++ write \U0001F600 in one piece. Accented text passes untouched everywhere.
Can it produce PowerShell or cmd.exe strings?
Not yet, on purpose: both differ from POSIX where it hurts, and a nearly-right shell escape is a security bug. They are planned for V2; the eight current grammars are exact.
Keyboard shortcuts
- ⌘/Ctrl + Enter
- Re-run the conversion now, at any input size.
- ⌘/Ctrl + S
- Download the output as .txt (a browser save-page override; the help overlay says so).
- ⌘/Ctrl + C
- Copy the whole output when nothing is selected; a selection copies itself.
- ⌘/Ctrl + Shift + C
- Copy the whole output even while a selection exists.
- s
- Flip escape ↔ unescape (idle in text fields, during IME composition, under the kill switch).
- t
- Advance to the next palette (the single-key guards apply).
- ? or ⌘/Ctrl + /
- Open the shortcut help overlay, browser conflicts included.
- Esc
- Dismiss the topmost overlay; the input always stays.