Convert a SQL IN clause to a list

Convert a SQL IN clause to a list by pasting the clause and reading one value per line back out. The tuple is found by the IN keyword, quotes are stripped, a doubled `''` unescapes to one quote, and a comma sitting inside a quoted literal does not split the value. This is the reverse of Convert List to SQL IN Clause.

Input
Ready
Output
Live

Get the values back out of a WHERE ... IN (...) filter

Convert a SQL IN clause to a list whenever you have copied a filter out of a query, a log line, or a bug report and need the values as rows you can sort, dedupe, or diff. Paste the whole fragment: the tool locates the parenthesised tuple that follows the `IN` keyword and ignores everything before and after it.

The tuple is then read with a quote-aware scan rather than a plain split on commas. A comma inside `'north, south'` stays part of the value, a doubled quote inside `'O''Brien'` becomes one apostrophe, and both single and double quoted literals are accepted. Unquoted numeric values such as `IN (101, 102)` come through as-is. Only the standard doubled-quote escape is understood, so a MySQL-style backslash escape, a function call, or a subquery inside the tuple will not parse cleanly.

Everything runs locally in your browser, so a production filter full of customer IDs stays on your machine. Once you have the list, find duplicates, diff it against another list, or export it as CSV.

How to use convert a sql in clause to a list

  1. 1Paste the IN clause, or the whole WHERE fragment, into the input panel.
  2. 2Read the values in the output panel, one per line, with the quoting removed.
  3. 3Leave Trim on to drop the spaces that sit between the commas and the values.
  4. 4Turn on Dedupe to collapse a tuple that repeats the same value.
  5. 5Copy the list, or hit Download to save it as a plain text file.

Keyboard shortcuts

Drive ListShift without touching the mouse.

Shortcut Action
Ctrl ZUndo last input change
Ctrl Shift ZRedo
Ctrl Shift EnterToggle fullscreen focus on the editor
EscExit fullscreen
Ctrl KOpen the command palette to jump to any tool
Ctrl SSave current pipeline draft Plus
Ctrl PRun a saved pipeline Plus

What the SQL IN clause parser does

Five concrete behaviours that decide what lands on each line.

The IN keyword locates the tuple

The first `IN (` in the input marks the start, and a quote-aware scan finds its matching close paren. Text before and after is discarded, so `AND status IN ('open','closed') AND active = 1` yields just `open` and `closed`.

A comma inside a quoted literal does not split

Values are read with a scanner that tracks quote state, not by splitting the string on commas. `IN ('north, south', 'east')` gives two values, the first of which is `north, south` with its comma intact.

Doubled quotes unescape to one character

SQL escapes a literal quote by doubling it, so `'O''Brien'` is one value and comes back as `O'Brien`. This exactly reverses what Convert List to SQL IN Clause writes.

Single quotes, double quotes, and no quotes all parse

Whichever your engine emits is accepted, and the outer quotes are always removed. An unquoted numeric tuple such as `IN (101, 102, 103)` comes through unchanged, one number per line.

A bare tuple or bare list still parses

With no `IN` keyword the first parenthesised group is used instead, and with no parentheses at all the whole input is read as the value list. Pasting `'a', 'b', 'c'` on its own works.

Worked example

The comma inside `north, south` is protected by its quotes, the doubled quote in `O''Brien` unescapes to one apostrophe, and the `AND active = 1` after the tuple is ignored.

Input
AND region IN ('north, south', 'east', 'O''Brien') AND active = 1
Output
north, south
east
O'Brien

Settings reference

How each option changes the output, using the sample clause above as the input.

Setting What it does Effect on the sample
Trim: on (default) Removes the whitespace around each value Gives alice, bob, carol, O'Brien with no leading space
Trim: off Keeps the spaces that followed each comma Lines 2 to 4 start with a space
Dedupe: on Collapses repeated values, keeping first-seen order No repeats in the sample, so no change
IN keyword (automatic) Marks where the tuple starts; a quote-aware scan finds its close paren The WHERE customer_id prefix is ignored
Quoting (automatic) Outer single or double quotes are removed from every value alice, not 'alice'
Doubled quotes (automatic) A doubled quote inside a literal becomes one character O''Brien becomes O'Brien
Quoted commas (automatic) A comma inside quotes stays part of the value Not exercised by the sample; see the worked example
Empty cells (automatic) A cell that is empty after trimming is dropped No blank lines in the output

FAQ

Can I paste the whole WHERE clause, not just the parentheses?
Yes. The first `IN (` marks the start of the tuple and a quote-aware scan finds its matching close paren, so anything before or after the tuple is ignored.
What happens to a comma inside one of the values?
It stays. Values are read with a scanner that tracks quote state rather than by splitting on commas, so `'north, south'` comes back as one value with its comma.
How are escaped quotes handled?
A doubled quote is SQL's way of writing a literal quote, so `'O''Brien'` unescapes to `O'Brien`. That is exactly what the forward tool writes, so the pair round-trips.
Does it work on a numeric IN clause?
Yes. `IN (101, 102, 103)` gives three lines with no quoting to strip. Unquoted values are passed through as text, since the list is plain text either way.
What if there are two IN clauses in what I paste?
Only the first is read. The scan stops at the close paren that matches the first `IN (`, so a second clause later in the statement is ignored. Paste them one at a time.