SQL Escape / Unescape

Double the single quotes in text so it fits inside a SQL string literal ('O''Brien'), or turn doubled quotes back into one — in your browser.

Suggested tools

SQL Formatter

Beautify or minify SQL queries in your browser.

SQL
Open Tool

JSON Escape / Unescape

Turn text, JSON or XML into a JSON string literal, or unescape it back.

JSONTEXT
Open Tool

HTML Escape / Unescape

Encode < > & " ' as HTML entities, or decode entities back to text.

HTML
Open Tool

XML Escape / Unescape

Make text safe for XML elements and attributes, or decode it back.

XML
Open Tool

JavaScript Escape / Unescape

Turn text into a safe JS string literal, or unescape it back.

JavaScript
Open Tool

Java Escape / Unescape

Escape text for Java strings and .properties files, or unescape it.

Java
Open Tool

About SQL Escape / Unescape

SQL Escape prepares text to be placed inside a single-quoted SQL string by doubling every single quote — so O'Brien becomes O''Brien, which is the standard escaping in MySQL, PostgreSQL, SQL Server, Oracle and SQLite. Unescape turns doubled quotes back into one.

Use it for one-off queries, migration scripts and test data. In application code, always use parameterised queries instead of building SQL strings. Everything runs locally in your browser — the text you paste is never uploaded.

How to use SQL Escape / Unescape

  1. Paste the text you want to put inside quotes, or an escaped SQL string.
  2. Press Escape or Unescape.
  3. Paste the result between single quotes in your query.

Key features

  • Standard SQL quote doubling ('')
  • Works for MySQL, PostgreSQL, SQL Server, Oracle and SQLite
  • Unescape for reading values back
  • Escape and Unescape on one page

Example

Ready to place between single quotes: WHERE note = '…'.

Input
O'Brien's order
Output
O''Brien''s order

When to use SQL Escape / Unescape

  • Writing names like O'Brien into hand-written SQL or migration scripts.
  • Preparing seed data that contains apostrophes.
  • Reading values with doubled quotes from SQL dumps.

Tips and common problems

  • In application code, always use parameterised queries instead of escaping by hand.
  • MySQL also treats backslash as an escape character by default; double backslashes too.
  • Escape only the value, then wrap it in single quotes in the query.

Frequently asked questions

Quote doubling handles quotes in string literals, but the safe way to use user input in applications is parameterised queries (prepared statements). Use this tool for hand-written SQL, not as a security layer.