SQL String Escape Tool

Escape single quotes, backslashes, and special characters in strings for safe SQL queries.

Options

Escape Rules by Dialect

Dialect Single quote Backslash NULL byte
MySQL \' \\ \0
PostgreSQL '' no change removed
SQLite '' no change removed
MSSQL '' no change removed

Summary

Escape single quotes, backslashes, and special characters in strings for safe SQL queries.

How it works

  1. Paste or type your raw string into the input field.
  2. Select the SQL dialect that matches your database (MySQL, PostgreSQL, SQLite, or MSSQL).
  3. The escaped output appears instantly, ready to paste into your SQL statement.
  4. Use the Copy button to copy the escaped value to your clipboard.
  5. Toggle "Wrap in quotes" to include the surrounding single quotes in the output.

Use cases

  • Escape user-supplied input before building a raw SQL query string.
  • Prepare string literals for database seed scripts and migration files.
  • Debug query building by seeing exactly how a value will appear inside SQL.
  • Convert multi-line or binary strings into SQL-safe representations.
  • Test escaping behavior across different database engines.
  • Quickly escape JSON blobs or HTML snippets stored in TEXT columns.

Frequently Asked Questions

Last updated: 2026-06-09 · Reviewed by Nham Vu