Text to unescape

SQL Dialect:

Unescaped text

Why unescape SQL text?

Unescaping SQL is useful when you need to convert escaped SQL strings back to their original form. This can be helpful when working with SQL scripts, debugging database queries, or processing data that has been previously escaped for SQL storage.

Examples of SQL unescaping

Escaped text

SELECT * FROM users WHERE username = ''john'' AND password = ''p@ss''''word'';
INSERT INTO messages (sender, content) VALUES (''O''''Reilly'', ''Hello, this is a "test" message'');
UPDATE products SET description = ''This product''s name is "Super Product"'' WHERE id = 123;
DELETE FROM logs WHERE entry LIKE ''%error%'' AND timestamp < ''2023-01-01'';
-- This is a comment with special chars: '', ", \, \n

Unescaped text (standard)

SELECT * FROM users WHERE username = 'john' AND password = 'p@ss''word';
INSERT INTO messages (sender, content) VALUES ('O''Reilly', 'Hello, this is a "test" message');
UPDATE products SET description = 'This product's name is "Super Product"' WHERE id = 123;
DELETE FROM logs WHERE entry LIKE '%error%' AND timestamp < '2023-01-01';
-- This is a comment with special chars: ', ", \, \n

SQL Unescaping by Dialect

Standard SQL

In standard SQL, doubled single quotes are unescaped to a single quote:

  • Doubled single quote ('') becomes '

Example: 'O''Reilly' becomes 'O'Reilly'

MySQL

MySQL uses backslash escaping for special characters, which are unescaped as follows:

  • Escaped single quote (\') becomes '
  • Escaped double quote (\") becomes "
  • Escaped backslash (\\) becomes \
  • Escaped newline (\\n) becomes \n
  • Escaped carriage return (\\r) becomes \r
  • Escaped tab (\\t) becomes \t
  • Escaped null byte (\\0) becomes \0
  • Escaped Ctrl+Z (\\Z) becomes \x1a

Example: 'O\'Reilly' becomes 'O'Reilly'

PostgreSQL

PostgreSQL primarily uses doubled single quotes for escaping, which are unescaped as follows:

  • Doubled single quote ('') becomes '

Example: 'O''Reilly' becomes 'O'Reilly'

Note: PostgreSQL also supports the E'' syntax for strings with escape sequences, but this tool focuses on the standard escaping method.

SQL Server (MSSQL)

SQL Server uses doubled single quotes for escaping, which are unescaped as follows:

  • Doubled single quote ('') becomes '

Example: 'O''Reilly' becomes 'O'Reilly'

When to use SQL unescaping

  • When analyzing or debugging SQL queries that contain escaped strings
  • When extracting data from SQL scripts for use in other contexts
  • When processing SQL data that needs to be displayed in a human-readable format
  • When converting between different SQL dialects that use different escaping conventions

Note:

This tool is designed to reverse the escaping process for SQL strings. It's particularly useful when working with SQL scripts or when you need to extract the original text from escaped SQL strings for further processing or display.

Other tools

Other tools available on this website: