jsonecho

SQL Escape

Paste your text and get it escaped for SQL, ready to paste into code or data.

Loading the tool...

How to use SQL Escape

  1. Paste or type the text you want to escape.
  2. Adjust the options if you need to.
  3. Copy the escaped result.

About SQL Escape

The apostrophe is the quote character for SQL strings, so a name like O'Brien ends the string early and breaks the statement. In standard SQL the fix is to double it: 'O''Brien'. MySQL also accepts a backslash.

A word of caution up front. Escaping by hand is fine for a one-off script or a migration, but for application code, use parameterised queries. They are the only reliable protection against SQL injection.

What gets escaped

Standard SQL: a single quote becomes two single quotes. MySQL style: backslash, single and double quotes, NUL, line breaks and Ctrl+Z get a backslash.

Frequently asked questions

Is escaping enough to stop SQL injection?

No. Use prepared statements with bound parameters. Manual escaping is easy to get wrong, especially with character sets and different SQL modes.

Which dialect should I choose?

Standard doubling works in PostgreSQL, SQL Server, SQLite and Oracle, and in MySQL unless NO_BACKSLASH_ESCAPES is set. The MySQL style is for text that will be run in MySQL, where backslashes are escape characters.

Why does PostgreSQL ignore my backslashes?

By default PostgreSQL treats backslashes in normal strings as plain characters. Use the standard style, or an E'...' string if you want backslash escapes.

What about LIKE patterns?

Percent and underscore are wildcards in LIKE and need their own escape character, which this tool does not add.

More in Escape and Text

All tools →