ForHosting KIT · Developer Utilities

Build a parameterized SQL WHERE clause from filters

Turn a structured list of application filters into the two pieces a database client needs: a SQL WHERE clause with positional placeholders and a separate ordered parameter array.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

Runs in your browser. Free, unlimited — your data never leaves this page.

Every field name is quoted as an SQL identifier, including each segment of a qualified name, while values remain outside the SQL text. Filters are kept in their original order and joined with AND, making the result predictable for query builders, admin tools, report screens, and server endpoints that already collect filters as data.

Build SQL structure without concatenating values

Dynamic search screens often begin with harmless-looking records such as a field, an operator, and a value. The dangerous step is turning those records into SQL by inserting the value directly into a string. This builder keeps structure and data separate. It returns a parameterized SQL WHERE clause containing PostgreSQL-style positional placeholders such as $1 and $2, plus a params array in exactly the matching order. Pass the clause into the larger SELECT, UPDATE, or DELETE statement and give the params array to a compatible database driver. The builder does not execute a query, connect to a database, inspect a schema, or decide which columns a caller may use. Your application should still maintain an allowlist when users can influence field names. Identifier quoting prevents punctuation and reserved words from breaking the generated syntax, but authorization remains an application concern. Because filters are joined by AND in the supplied order, the output is stable and easy to snapshot, log, compare, or combine with an existing fixed query prefix.

Understand operators, placeholders, and null checks

The supported comparison operators are equality, inequality, ordering comparisons, LIKE, NOT LIKE, IN, NOT IN, IS NULL, and IS NOT NULL. Operator text is normalized to uppercase and repeated whitespace is collapsed, so a human-friendly spelling such as “not like” produces canonical SQL. Every ordinary comparison consumes one parameter. IN and NOT IN require a non-empty value array and expand it into one placeholder per element, preserving array order. Null-check operators consume no parameter and do not require a value because their SQL grammar contains no placeholder. A missing value for any other operator is rejected instead of silently generating incomplete SQL. JSON scalar values are accepted, including strings, numbers, booleans, and null; arrays are reserved for the two list operators. The result deliberately uses numbered dollar placeholders, which suit PostgreSQL and libraries that accept that convention. If your driver uses question marks or named parameters, translate the placeholder syntax in a controlled adapter while preserving the returned parameter order.

Quote identifiers and validate application policy

Each field is treated as a possibly qualified identifier. A name such as users.created_at becomes two separately quoted segments, while an embedded double quote is escaped by doubling it according to standard SQL identifier rules. Empty names and empty dotted segments are rejected. This treatment stops a field string from being confused with unquoted SQL syntax, but it intentionally does not claim that every database engine has identical quoting behavior. Confirm compatibility with your target database, especially if it does not follow double-quoted identifier conventions. More importantly, escaping is not the same as permission. If an external caller selects fields, map public filter keys to an explicit set of real columns before invoking the builder. Do the same for business-level operator rules: a reporting endpoint may permit equality and ranges while refusing pattern searches even though the builder supports LIKE. Unsupported SQL operators always produce an input error, which gives callers a clear failure instead of passing unfamiliar syntax through. The capability is deterministic, performs no network requests, and returns only the clause and parameters.

Power an API filter endpoint

Convert validated query-string filters into a clause and ordered parameters for a database request.

Build an internal report query

Turn report-builder rows into predictable AND predicates without inserting report values into SQL text.

Generate testable repository queries

Snapshot the deterministic clause and parameter array separately when testing a data-access layer.

What does it cost?

Each API request starts at $0.002. The browser runner is available for interactive use.

Does this execute the SQL?

No. It only returns a WHERE clause and an ordered params array; your application supplies both to its database driver.

Which placeholder syntax is generated?

It generates PostgreSQL-style numbered placeholders: $1, $2, and so on.

Can I use IN and NOT IN?

Yes. Supply a non-empty array as the value, and the builder creates one placeholder for every array element.

How are null checks represented?

Use IS NULL or IS NOT NULL. These operators do not need a value and do not add an item to params.

Does identifier escaping replace a column allowlist?

No. Quote escaping protects syntax, while an application allowlist decides which columns and qualified names a caller is authorized to filter.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/dev2/sql-where-builder

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/dev2/sql-where-builder \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"filters":[{"field":"users.status","operator":"=","value":"active"},{"field":"users.age","operator":">=","value":21}]}'
{
  "filters": [
    {
      "field": "users.status",
      "operator": "=",
      "value": "active"
    },
    {
      "field": "users.age",
      "operator": ">=",
      "value": 21
    }
  ]
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "dev2.sql_where_builder",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_items100
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Read the full KIT documentation →