Australian Jeevitham TECHDeveloper tools

Tech / String Escape & Unescape

String Escape & Unescape

Make text safe to paste into JSON, JavaScript, SQL, a shell command, a regular expression or a CSV file - or turn escaped text back.

Escape / unescape

Why escaping matters

Every language has characters with a special meaning. A double quote ends a JSON string, a single quote ends an SQL string, and $ or a space changes a shell command. Escaping marks those characters so they are read as plain text.

ForWhat this page does
JSON / JavaScriptAdds a backslash: " becomes \", a new line becomes \n
SQLDoubles single quotes: O'Brien becomes O''Brien
Shell (bash)Wraps the text in single quotes, so it is one argument with no special characters
Regular expressionAdds a backslash before characters such as . * + ? ( ) [ ]
CSVPuts a value with a comma, quote or new line in double quotes, and doubles the quotes inside

Should I escape SQL by hand in my code?

No. In real code, use query parameters (prepared statements), which keep data and commands apart and stop SQL injection. Hand escaping is only for one-off queries you type yourself. See the OWASP guide to preventing SQL injection.

What are Unicode escapes?

Some systems only accept plain English characters. With the Unicode option, other letters are written as codes - the Malayalam letter അ becomes അ - and turn back into the same letter when read.

Your text is escaped in your browser and is not uploaded.