FormatterHQ

SQL Unescape

Recover the original text from an escaped SQL string literal, in standard quote-doubling style or MySQL’s backslash style.

Loading tool…
Ready.

How to use the SQL Unescape

  1. Type or paste into the Escaped SQL box, or click Sample. You can also drop a text file on either box, or load one into the Escaped SQL box with its Open file button.
  2. The Raw text box updates live as you type. It works both ways — edit the Raw text side to convert back, or click ⇄ Swap to exchange the sides.
  3. Adjust Dialect in the options bar above the editors; the result refreshes immediately.
  4. Use Copy or Download on either box to take the result, or Clear to start again.

SQL unescape for dumps, logs and scripts

SQL dumps, query logs and generated migration files contain values in escaped form. The SQL unescape tool turns them back into readable text so you can inspect a value, copy it into a document or compare it with what the application stored.

Dialects

Standard SQL

Replaces every '' with a single '. That is the only escape in standard SQL, used by PostgreSQL, SQL Server, Oracle and SQLite.

MySQL (backslash)

Decodes the backslash sequences written by mysqldump and mysql_real_escape_string: \', \", \\, \0, \n, \r, \t, \b and \Z (Ctrl+Z). Doubled quotes are also collapsed, because MySQL accepts both styles.

Two sequences are intentionally kept: \% and \_. MySQL leaves the backslash in place for these so they still work as literal wildcards in LIKE patterns.

Example (MySQL mode)

Input:

It\'s O\'Brien\'s \"C:\\temp\"\nnext line

Output:

It's O'Brien's "C:\temp"
next line

Example (standard SQL)

Input:

Tom''s ''special'' order

Output:

Tom's 'special' order

Standard mode only touches doubled quotes, so backslashes, % signs and double quotes stay exactly as they are.

Typical uses

  • Reading a dump. Copy a long text value out of an INSERT statement in a backup file to see it with real line breaks.
  • Comparing data. Check whether a value in a migration script matches what users see in the application, without guessing how many quotes are escapes.
  • Debugging query logs. Slow-query and general logs record statements with values inlined and escaped; unescaping makes long text values readable.
  • Cleaning exports. Turn escaped values from a SQL export into plain text for a document or spreadsheet.

Paste only the contents of the literal — the part between the outer quotes. If you include the outer quotes, they stay in the output as ordinary characters.

Choosing the right mode

If the text contains backslash sequences such as \n and came from MySQL or MariaDB, use MySQL mode. For PostgreSQL pg_dump output or SQL Server scripts, use Standard SQL: in those databases a backslash is an ordinary character, and decoding it would change your data.

Escape text again with SQL Escape or reformat a whole dump with the SQL Formatter. Remember that when you write values back to a database from code, parameterised queries are the safe route rather than re-escaping by hand. Processing happens in your browser.

Frequently asked questions

Why do SQL dumps contain two single quotes?
Standard SQL escapes a quote inside a string by doubling it. 'It''s' is the SQL spelling of It's.
Why is \% not decoded to %?
MySQL keeps the backslash in \% and \_ so that they act as literal percent and underscore characters in LIKE patterns. The tool follows the same rule.
Can I use this for PostgreSQL E'…' strings?
The MySQL mode decodes the common backslash escapes that E-strings also use, such as \n and \\. PostgreSQL-specific forms like octal or \u escapes are not decoded.
Is it safe to paste production data here?
The tool runs locally in your browser and does not upload the text. Still, follow your organisation’s rules for handling personal or confidential data.

Last updated October 3, 2026

Related tools