01What is SQL Escape Tool?
Sooner or later every hand-written INSERT meets a customer called O'Brien. The apostrophe ends the string early and the query breaks, or worse. This tool turns raw text into a quoted SQL string literal, and it can turn a literal back into plain text. It knows three dialects, and they really do differ. Standard SQL follows the rule in the SQL standard: a quote inside a string is written as two quotes. So O'Brien becomes 'O''Brien'. Backslashes, newlines and tabs are left as they are, because the standard gives them no special meaning. MySQL (backslash) follows MySQL's documented escape sequences. It puts a backslash before backslashes, single quotes and double quotes. It also writes a newline as \n, carriage return as \r, tab as \t, a NUL byte as \0 and the Ctrl+Z character as \Z. PostgreSQL (E string) doubles quotes like the standard. If the text holds a backslash, newline or tab, it switches to PostgreSQL's E'...' escape-string syntax and backslash-escapes those characters. Plain PostgreSQL strings treat backslashes literally when standard_conforming_strings is on, which has been the default since version 9.1. That's why the switch is needed. Every result is wrapped in quotes and ready to paste. For example, C:\temp stays 'C:\temp' in Standard SQL but becomes E'C:\\temp' in PostgreSQL. Unescape mode trims the input, strips the outer quotes, including an E or e prefix, and reads the body in one left-to-right pass. Two quotes become one. In MySQL, sequences like \n, \t, \0 and \Z are decoded, while \% and \_ keep their backslash, as MySQL does. In PostgreSQL, backslashes only count inside an E'...' string. The single pass matters for 'C:\\new' in MySQL. The escaped backslash is read first, so the result is C:\new and not C: followed by a line break. Some limits are worth knowing. In PostgreSQL mode, a carriage return on its own doesn't trigger the E'...' form and is kept as a raw character, which is still valid SQL. MySQL output breaks if the server runs with NO_BACKSLASH_ESCAPES. Identifiers such as table names aren't handled at all. And as the note under the panes says, escaping is no replacement for bound parameters in application code. The text is escaped by script running on the page and stays in your browser.
Backend developers and DBAs who write SQL by hand for migrations, seed files and one-off fixes. The tool runs entirely in your browser, so your data never leaves your device.
02How to use SQL Escape Tool
- Pick Escape or Unescape from the Mode dropdown.
- Choose a Dialect: Standard SQL, MySQL (backslash) or PostgreSQL (E string).
- Paste your text into Input. The character count updates as you type.
- Copy the result from Output with the Copy button, or click Reset to start again.
03Worked examples
- Input:
O'Brien (Escape, Standard SQL) - Result:
'O''Brien' - The quote is doubled and the value wrapped.
- Input:
O'Brien (Escape, MySQL (backslash)) - Result:
'O\'Brien' - MySQL uses a backslash before the quote instead.
- Input:
C:\temp (Escape, Standard SQL) - Result:
'C:\temp' - Standard SQL leaves backslashes alone.
- Input:
C:\temp (Escape, PostgreSQL (E string)) - Result:
E'C:\\temp' - A backslash triggers the E'...' form, where it must be doubled.
- Input:
line1 + newline + line2 (Escape, MySQL (backslash)) - Result:
'line1\nline2' - The real line break becomes the two characters \n.
- Input:
'C:\\new' (Unescape, MySQL (backslash)) - Result:
C:\new - The escaped backslash is read first, so \n here is not a newline.
04Common use cases
- Writing an INSERT in a migration or seed file where a name or address contains an apostrophe
- Pasting a multi-line comment into a one-off UPDATE in psql, where it needs the E'...' form
- Recovering the original value from a MySQL slow-query log line full of \' and \n
- Building a quick data fix during an incident without hand-counting quotes
- Checking that a Windows path keeps its backslashes when moved between MySQL and PostgreSQL scripts
- Showing a junior developer how a stray quote breaks out of a concatenated query
05Tips
- If you aren't sure which dialect a script will run on, use Standard SQL. Doubled quotes work in MySQL, PostgreSQL, SQLite and SQL Server.
- In Unescape, a PostgreSQL literal without the E prefix keeps every backslash. Add the E if the logged value was an escape string.
- MySQL keeps \% and \_ as two characters when unescaping, since they are LIKE wildcards, not string escapes.
- Table and column names need identifier quoting and an allow-list. This tool only handles string values.
06Related concepts
SQL injection, string literal, prepared statements, escape sequences, SQL dialects.
Frequently Asked Questions
What is SQL Escape Tool?
SQL Escape Tool is a free, browser-based developer tool on AIDToolStack. Escape strings for safe SQL queries It requires no installation or sign-up and works entirely in your browser.
Is SQL Escape Tool free to use?
Yes. No sign-up, no fees and no usage cap.
Does SQL Escape Tool store my data?
No. It runs in your browser; nothing is uploaded.