What does the SQL Parameter Unbinder & Query Hydrator do?
The SQL Parameter Unbinder & Query Hydrator reconstructs fully executable SQL queries from parameterized statements extracted from application logs, ORM frameworks (Hibernate, Spring Data JPA, MyBatis, Prisma), or database drivers (PostgreSQL, MySQL, Oracle, MSSQL). It parses positional (?), numbered ($1, $2), and named (:name) placeholders and securely binds them with escaped string, numeric, boolean, UUID, or timestamp values.
Core Concepts
Understanding SQL parameter binding and unbinding rules:
- Placeholder Pattern Matching: Auto-detects positional
?wildcards, PostgreSQL numbered$nvariables, and named:identifierparameters. - Log Format Auto-Parsing: Extracts values from JSON arrays (
["val1", 21]), Hibernate binding logs (binding parameter [1] as [VARCHAR] - [active]), and pgAdmin parameter maps ($1 = 'active', $2 = 21). - Dialect-Safe Value Escaping: Escapes single quotes (
'') in strings, converts date strings to OracleTO_TIMESTAMP/TO_DATEcalls, and prevents SQL injection issues during debugging.
How to use the tool?
- Paste Parameterized SQL: Enter your SQL query containing placeholder markers (
?,$1,:id) or click Load Sample. - Paste Bound Parameters: Enter your parameters array (JSON array, Hibernate log lines, or comma-separated values).
- Compile & Copy: Select your target Database Dialect, click Compile Executable Query, and click Copy or Download to export the ready-to-run SQL.
Related Developer Utilities
If you work with database queries, SQL logs, and ORM debugging, explore these complementary tools:
- SQL Formatter & Query Beautifier: Format and beautify complex SQL statements across dialects.
- JSON Formatter: Format and inspect JSON parameter arrays.
- JSON Syntax Validator: Validate JSON parameter payloads and locate syntax errors.
- Text Diff Tool: Compare original vs hydrated SQL queries.
REST API Integration
Blueutils provides a free REST API endpoint (POST https://blueutils.com/api/sql/sql-parameter-unbinder) to programmatically hydrate and replace placeholders in parameterized SQL queries with correctly escaped parameter values.
API Request Parameters
| Name | Type | Description | Example |
|---|---|---|---|
rawText |
String | Parameterized SQL query containing placeholders. | "SELECT * FROM users WHERE status = $1 AND age > $2" |
paramsText |
String | Parameter values (JSON array, logs, or comma list). | "[ \"active\", 21 ]" |
dialect |
String | Database dialect: "postgresql", "mysql", "oracle", "mssql". |
"postgresql" |
beautify |
Boolean | Whether to apply standard capitalization and indentation. | true |
API Request Payload Examples
cURL
curl -X POST https://blueutils.com/api/sql/sql-parameter-unbinder \
-H "Content-Type: application/json" \
-d '{
"rawText": "SELECT * FROM users WHERE status = $1 AND age > $2",
"paramsText": "[\"active\", 21]",
"dialect": "postgresql",
"beautify": true
}'Python
import requests
url = "https://blueutils.com/api/sql/sql-parameter-unbinder"
payload = {
"rawText": "SELECT * FROM users WHERE status = $1 AND age > $2",
"paramsText": "[\"active\", 21]",
"dialect": "postgresql",
"beautify": True
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String jsonPayload = """
{
"rawText": "SELECT * FROM users WHERE status = $1 AND age > $2",
"paramsText": "[\\"active\\", 21]",
"dialect": "postgresql",
"beautify": true
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://blueutils.com/api/sql/sql-parameter-unbinder"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}API Response Parameters
| Name | Type | Description | Example |
|---|---|---|---|
isValid |
Boolean | Indicates whether parameter binding succeeded. | true |
unboundQuery |
String | Fully compiled executable SQL query. | "SELECT *\nFROM users\nWHERE status = 'active'..." |
parameterCount |
Number | Count of parameters mapped and substituted. | 2 |
API Response Payload Examples
Success Response (HTTP 200 OK)
{
"isValid": true,
"unboundQuery": "SELECT *\nFROM users\nWHERE status = 'active'\n AND age > 21",
"parameterCount": 2
}Validation Failure Response (HTTP 400 Bad Request)
{
"isValid": false,
"error": "Query input cannot be empty."
}Rate Limit Exceeded Response (HTTP 429 Too Many Requests)
{
"error": "API rate limit exceeded. Please wait or contact support@blueutils.com."
}Why use an API to unbind SQL parameters?
Integrating the SQL Parameter Unbinder API into backend observability dashboards, log aggregation pipelines, or AI agent tool calling provides key benefits:
- Rapid Script Validation: Converts raw split logs from production tracing tools directly into runnable SQL queries for debugging.
- Optimized Token Efficiency for AI Agents: LLMs frequently misalign positional
?or$nplaceholders when hydrating parameters. Calling the API extracts the complete query deterministically without hallucination. - Deterministic Accuracy Without Hallucinations: Ensures 100% dialect-safe string quote escaping and timestamp formatting.
Native Usage
How to unbind SQL parameters locally in terminal environments or scripts:
Windows (CMD / PowerShell)
# Sequentially replace query placeholders in PowerShell
$sql = "SELECT * FROM users WHERE status = ? AND age > ?;"
$params = @("'active'", "21")
foreach ($p in $params) {
$indexOf = $sql.IndexOf('?')
if ($indexOf -ge 0) {
$sql = $sql.Remove($indexOf, 1).Insert($indexOf, $p)
}
}
Write-Output $sqlLinux / Unix (Bash)
# Simple replacement using Python in Linux
python3 -c "
sql = 'SELECT * FROM users WHERE status = ? AND age > ?;'
params = [\"'active'\", '21']
for p in params:
sql = sql.replace('?', p, 1)
print(sql)
"Python
Using Python:
def unbind_sql(sql, params):
for p in params:
val = f"'{p}'" if isinstance(p, str) else str(p)
sql = sql.replace("?", val, 1)
return sql
query = "SELECT * FROM users WHERE status = ? AND age > ?;"
params = ["active", 21]
print(unbind_sql(query, params))Java
Using Java:
public class SqlUnbinderExample {
public static String unbind(String sql, Object[] params) {
String result = sql;
for (Object p : params) {
String val = (p instanceof String) ? "'" + ((String) p).replace("'", "''") + "'" : String.valueOf(p);
result = result.replaceFirst("\\?", val);
}
return result;
}
public static void main(String[] args) {
String sql = "SELECT * FROM users WHERE status = ? AND age > ?;";
Object[] params = {"active", 21};
System.out.println(unbind(sql, params));
}
}