String Literal Escaper
Escape a block of text for safe use as a string literal in JavaScript, Python, Java, C#, Go, JSON, SQL or shell.
What is String Escaper?
A tool for the moment after you paste prose into a code editor and realise it contains quotes, Windows paths and a hard line break. It escapes the text so the literal is valid and the value is exactly what you typed.
How it works
Each language gets its own rules rather than one shared pass. C-family languages escape with backslashes and write control characters as `\uXXXX`; SQL doubles the quote character; shell wraps in single quotes and closes-reopens for an embedded quote, which is the only portable form. Options control the surrounding quotes and whether they are included at all.
- Paste the source. Drop in code, a stylesheet, a query or a selector list. Everything is read locally — the page never uploads what you paste.
- Choose the options. Indent width, quote style, keyword case or target browsers. The result updates as you change them, so you can see the effect immediately.
- Copy or download. Copy the result to the clipboard or download it as a file. Reset clears the form and returns every option to its default.
Examples
A Windows path in a JSON config
`C:\Users\me\notes.txt` becomes `C:\\Users\\me\\notes.txt` so the JSON parser sees the backslashes you meant.
Multi-line prose in a SQL string
An apostrophe is doubled instead of backslash-escaped, which is what the SQL standard requires and what keeps the statement valid.
Common mistakes
Expecting a formatter to fix invalid code
Formatting is whitespace and quoting. A missing brace, an unclosed tag or an unquoted variable survives the round trip and is reported instead — check the findings list.
Minifying without running the tests afterwards
Even a safe, non-mangling minifier can expose an existing automatic-semicolon-insertion bug. The JavaScript Minifier keeps the newlines that matter, but re-run your tests before shipping.
Treating a rewritten query as verified
The SQL Dialect Converter translates the syntax it can prove; data types, casts and function differences are listed for review, not guessed. Run the converted query against a real database.
Renaming or reformatting generated files
Regenerating a formatter's output is a no-op only if the formatter is the same one that produced it. Keep generated code out of the round trip and format the source it came from.
Frequently asked questions
Why does the shell option use single quotes?
Because inside double quotes the shell still expands `$`, backticks and backslashes. Single quotes are the only form where the value is passed through literally, and `'\''` is how a single quote is embedded safely.
Which quote character should I choose?
Whichever your codebase already prefers — the escaped result is equivalent. The exception is Shell, where single quotes are safer, and SQL, where only single quotes are standard.
Does it change my text?
No. Escaping preserves the value exactly: unescaping the produced literal gives back the text you pasted, including leading whitespace and any trailing spaces.