SQL String Escaper

Escape single quotes and backslashes for safe SQL literals

Ad placeholder (leaderboard)

Placing a value inside a SQL string literal means escaping it so a stray quote cannot break out of the string. This tool applies the correct rule for your dialect: ANSI quote-doubling, or MySQL’s additional backslash handling.

How it works

Standard SQL needs only quote-doubling. MySQL, by default, also treats the backslash as special, so more characters must be escaped:

Standard:  '  -> ''
MySQL:     '  -> ''    \ -> \\    NUL -> \0
           newline -> \n   carriage return -> \r   tab -> \t

In both modes the result is the body of the literal; turn on the wrap option to get it enclosed in single quotes as a ready-to-use literal.

Tips and notes

This tool is for ad-hoc queries, test fixtures, and learning — never build production queries from untrusted input by string-escaping. Use prepared statements or parameter binding, which sidestep escaping entirely and are immune to injection. If your MySQL server runs with NO_BACKSLASH_ESCAPES, backslashes are ordinary characters, so use Standard mode, which also matches PostgreSQL and most other engines.

Ad placeholder (rectangle)