Skip to content
OnlineToolStudio

SQL Escape / Unescape

runs in your browserno sign-upfree

Escape text for an SQL string: double single quotes ('') or MySQL backslash escapes.

Escaped

21 chars

About this tool

This tool escapes text so it can be placed inside an SQL string literal. The standard way, which works in every database, doubles each single quote: O'Reilly becomes O''Reilly. MySQL and MariaDB also accept backslash escapes (\' \n \\), which you can choose instead. Unescape reverses either style.

How to use

  1. Choose the style: Standard ('') or MySQL (\').
  2. Choose Escape or Unescape and paste your text.
  3. Optionally wrap the result in single quotes, then copy it.

FAQ

Should I build queries with escaped strings?

For application code, no — use prepared statements or parameters (for example ? or $1 placeholders), which keep data separate from SQL and prevent SQL injection. This tool is handy for one-off queries, seed files and migrations.

Which style should I use?

Standard ('') works in MySQL, PostgreSQL, SQL Server, SQLite and Oracle. Use MySQL (\') only for MySQL or MariaDB with default settings.

Is my text uploaded?

No. Escaping runs entirely in your browser, so your text never leaves your device.

Related tools

All tools