SQL IN Clause Builder

Turn a list of values into a ready-to-paste SQL IN (...) clause.

Paste a list of IDs or values and get a clean SQL IN clause instantly — auto-quoting, de-duplication, NOT IN, and one-per-line formatting. Runs entirely in your browser, nothing is uploaded. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

How does auto-quoting decide what to quote?

In auto mode, a value that matches a clean number pattern (optional sign, digits, optional decimal) is left unquoted; everything else is wrapped in single quotes with any embedded single quotes doubled for SQL safety.

Have a column of IDs from a spreadsheet, log, or query result and need them inside a WHERE id IN (...)? Paste the list and this tool assembles a clean, correctly quoted SQL IN clause ready to drop into your query.

How it works

The builder runs a small pipeline:

  1. Split the input on newlines, commas, semicolons, or tabs, trim each piece, and drop empties.
  2. De-duplicate (optional) by keeping the first occurrence of each value.
  3. Quote each value. In auto mode, anything matching a clean number pattern stays bare and everything else is wrapped in single quotes with ' escaped as ''. You can also force always-quote or never-quote.
  4. Assemble column IN (...) — or NOT IN if toggled — joining values inline, or one per indented line in multiline mode.

Examples

Pasting 1001, 1002, 1002, 1007 with column id, auto quoting, de-dupe on:

id IN (1001, 1002, 1007)

A list of strings like GB, US, FR becomes:

country IN ('GB', 'US', 'FR')

Long lists are easier to read and diff in multiline mode:

user_id IN (
    1001,
    1002,
    1007,
    1015
)
OptionEffect
Auto quotingNumbers bare, strings single-quoted
De-duplicateRemoves repeated values
NOT INSwaps IN for NOT IN
MultilineOne value per indented line

When to use IN vs alternatives

IN is the right choice when you have a short or medium list of discrete values (up to a few hundred at most). For very large lists, consider alternatives:

Temporary table or CTE. Load your list into a temporary table and join to it. This scales to millions of rows, uses an index, and is far faster than a thousand-value IN list, which forces the database to scan or build a large set for each row comparison.

= ANY(ARRAY[...]) in PostgreSQL. Semantically the same as IN but sometimes lets the planner choose a better execution path for larger arrays.

NOT IN with NULLs. Be careful: if any value in a NOT IN list is NULL, the entire expression evaluates to UNKNOWN, and no rows are returned. Use NOT EXISTS or a LEFT JOIN ... IS NULL pattern when the exclusion list may contain nulls.

For lists you assemble from a spreadsheet export or CSV, this tool handles the most common case: turn a raw column of values into a safe, quoted IN clause in seconds without writing a script.

Everything runs in your browser — nothing is uploaded.