SOQL → Apex String Literal
Wrap a SOQL query as a paste-ready Apex string literal: handles single-quote and backslash escaping for you.
SOQL
Apex
Output appears here.Wrap a SOQL query as a paste-ready Apex string literal: handles single-quote and backslash escaping for you.
Output appears here.Pasting a SOQL query into an Apex string literal is one of those small but error-prone tasks: every embedded single quote needs to become `\'`, every backslash needs to double, and (for `Database.query`) you have to make sure you don't accidentally break a bind variable. This tool wraps any SOQL query in a paste-ready Apex string with the escaping handled for you, ready to drop into a Database.query() call.
The tool reads the SOQL as a raw string, walks each character once, and emits the Apex-string equivalent: backslashes double, single quotes get a leading backslash, newlines convert to `\n`, and bind variables (`:varName`) are left as Apex string interpolation hints. The output is wrapped in a single pair of quotes so you can copy-paste it directly into a `Database.query(...)` argument or a constant declaration.