Escape strings for safe SQL queries. Fast, secure, and completely free. All processing happens in your browser — no data is sent to any server.
SQL escaping converts characters that have special meaning inside a SQL string literal — primarily single quotes — into a form that won't prematurely terminate the string or alter the query's structure. A single quote inside a value like O'Brien needs to become O''Brien (or use the dialect's specific escape syntax) before it's safe to place directly inside a quoted SQL literal. This tool exists purely to help you understand and inspect that escaping, not to replace parameterized queries — using bound parameters/prepared statements remains the correct way to handle untrusted input in real application code.
Even with parameterized queries as the standard for production code, there are legitimate reasons to need manual SQL escaping: writing a one-off migration script, debugging a query by reconstructing exactly what a driver sent to the database, or understanding how an ORM's query logging escapes values. This tool shows you precisely how a given string transforms so you can spot exactly where a hand-written query would break on an apostrophe or other special character — and understand, concretely, why building queries via string concatenation is risky.
No — manual escaping should never be your primary defense against SQL injection in real code. Always use parameterized queries or prepared statements, which handle escaping correctly and safely at the driver level.
In standard SQL, doubling a single quote inside a string literal is the classic way to represent a literal apostrophe without ending the string early.
Escaping character-by-character can help in very narrow, controlled contexts, but it's fragile and dialect-dependent — parameterized queries eliminate the entire class of injection risk far more reliably.
The doubled single-quote convention is broadly consistent across ANSI SQL, though some dialects and drivers offer additional escaping mechanisms — always confirm the exact convention your database and driver expect.
Yes, depending on the dialect selected, backslashes are handled according to that database's specific escaping rules.