Escape a string for SQL

Escape SQL values or identifiers for a selected dialect.

freeworks offlinenothing uploaded
ToolSQL Escape
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

Values use doubled quote characters or parameter placeholders, while identifiers use a separate delimiter rule. The result is a fragment and not a complete query or authorization check.

  • Parameters are preferred for application values.
  • Dialect-aware quoting remains useful for static fixtures and identifiers.

Worked example

Escape User Input
Escape a string containing single quotes for safe SQL insertion
Input
											O'Brien's "test" value
										
Output
												O''Brien''s ""test"" value
											

When to use this

Seed files, migrations, and query-builder fixtures escape SQL text.

Edge cases

  • Apostrophes need doubling or parameters.
  • String quotes and identifier quotes are not interchangeable.
  • Backslash behavior varies by dialect and server settings.

References