SQL Parameter Formatter
Rewrite SQL placeholders between styles such as ? , $1, :name, @name, %s or {0}, numbering positional parameters in order and listing the bindings, locally in your browser.
- Runs locally in your browser
- No upload required
Capabilities
- Download result
Try it
Supported formats
Privacy
Runs entirely in your browser. Your input is never uploaded, stored, or sent to a third party.
Converted 2 placeholder(s) from ? (positional) to $1 (numbered).
How it works
- Tokenised the query and collected the real parameter tokens.
- Numbered the parameters in source order.
- Emitted each placeholder in the target style.
- Parameters inside strings, quoted identifiers and comments are ignored.
Methodology
- Tokenise the query and collect only the real parameter tokens, ignoring anything inside strings or comments.
- Determine the source style from the first placeholder and number the parameters in source order.
- Emit each placeholder in the requested target style.
Usage
- Paste a query that contains placeholders.
- Choose the source dialect and the target placeholder style.
- Run the formatter and copy the rewritten query or the parameter list.
Examples
These are examples, not current values: they use fixed inputs, while the interactive tool computes live results in your browser.
Positional to numbered
{
"text": "select * from t where a = ? and b = ?",
"dialect": "mysql",
"targetStyle": "dollar-numbered"
}Numbered to named
{
"text": "select * from t where a = $1 and b = $2",
"dialect": "postgresql",
"targetStyle": "named-colon"
}Named to positional
{
"text": "select * from t where a = :a and b = :b",
"dialect": "standard",
"targetStyle": "question"
}Limitations
One query, many drivers
The same query is written with different placeholders depending on the driver. Converting them by hand is error-prone; doing it from the token stream keeps ordering exact.
Frequently asked questions
- What happens to a ? inside a string?
- It is left untouched. Only placeholders outside strings, identifiers and comments are converted.
- Are named parameters preserved?
- When converting to a named style the names are kept; converting to a positional style replaces them with p1, p2, … in order.
- Does this run my query?
- No. It rewrites the text in your browser and never connects to a database.
Sources
- ISO/IEC 9075-1:2023: Information technology, Database languages SQL — ISO/IEC
- PostgreSQL Documentation: SQL Syntax, Lexical Structure — PostgreSQL Global Development Group
- MySQL 8.0 Reference Manual: String Literals — Oracle
- SQLite Documentation: SQL Syntax — SQLite Consortium
- Microsoft Learn: Transact-SQL Syntax Conventions — Microsoft
Send feedback
Tell us if this tool helped, report a problem, or suggest a tool. Only the message you type is sent — never the input you used in the tool.
Was this tool useful?
Prefer to write to us directly? See the contact page.