String Escaper
Get text into a form that can be pasted safely between quotes in code or data files. Pick the target format and the result updates as you type: quotes, backslashes, line breaks and control characters are escaped according to that format's rules. Switch to Unescape to turn an escaped literal back into plain text.
Escape or Unescape a String
Result
Notes
How to Use the String Escaper
- Choose Escape or Unescape.
- Pick the format, and tick Add surrounding quotes if you want them.
- Type or paste the text; the result appears below.
- Copy the result.
About This Tool
Developers embedding text in source code, JSON fixtures or SQL scripts, and anyone cleaning up escaped strings copied from logs.
Input: Text · Output: Escaped text.
Features and Limitations
Features
- Eight targets including template literals and both SQL quoting styles.
- Unescaping uses careful hand-written parsers with clear error positions, never eval.
- Handles control characters, NUL, and the U+2028/U+2029 separators that break older JavaScript.
- Warns about spreadsheet formula injection for CSV values.
Limitations
- SQL escaping is not a substitute for parameterised queries.
- HTML escaping here is for attribute values and text, not for building trusted HTML from user input.
- Legacy JavaScript octal escapes such as \101 are not decoded.
- Results are computed in your browser; nothing you enter is sent to a server.
Example
Escaping She said "hi" for JSON gives
She said \"hi\"; for a standard SQL literal
O'Brien becomes O''Brien.
Frequently Asked Questions
What is the difference between JSON and JavaScript escaping?
JSON only allows double-quoted strings and a fixed set of escapes. JavaScript also has single quotes, template literals and \x / \u{…} escapes.
Should I escape SQL values myself?
Prefer prepared statements with placeholders. Use escaping for hand-written scripts, migrations and test data.
Why does MySQL need a separate option?
MySQL treats backslash as an escape character in strings by default, so backslashes and quotes are escaped differently than in standard SQL.
Is my text processed on a server?
No. Everything happens in your browser.
Related Tools
More like this: all Encoding & Security tools, all Developer & Web tools or the TinySandy home page.