SQL IN Clause Generator

Paste a column of ids, emails or codes, one per line, and get an IN (...) list ready for a WHERE clause.

How it works

Values are read one per line, the way a column pastes from a spreadsheet. A single line is split on commas or tabs instead. Spaces around each value and blank lines are dropped.

If every value is a plain number, the numbers are left bare: IN (7, 12, 31). If any value is text, every value is quoted, and a quote inside a value is doubled, so O'Brien becomes 'O''Brien'. A number with a leading zero, such as 007, counts as text, because a zip code or an account number would lose its zero as a number.

Oracle refuses an IN list of more than 1,000 values. Type a column name and turn on the Oracle option, and a longer list is split into lists of 1,000 joined with OR. Everything runs on this page.

How to use it

  1. 1 Paste your values into the Values box, one per line.
  2. 2 Choose whether numbers stay bare or every value is quoted, and whether duplicates are removed.
  3. 3 Type a column name if you want it written in, and turn on the Oracle option for lists over 1,000.
  4. 4 Copy the SQL, or download it as a .sql file.

Good to know

  • Quote every value when the column is a text type, even if the values look like numbers. Comparing a text column with a number can make the database convert every row, which is slow and can fail.
  • The note under the result counts the values and the duplicates removed. Check it against the number of rows you copied.
  • For thousands of values, a temporary table and a join is usually faster than a huge IN list.
  • In PostgreSQL you can also write = ANY(ARRAY[...]) with the same values.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

From a spreadsheet column to WHERE customer_id IN (...), without the hand editing

The job comes up all the time. Someone sends a spreadsheet of 300 customer ids and asks what happened to those accounts. The query is simple, WHERE customer_id IN (...), but the list has to be typed by hand: a comma after every value, quotes around every text value, and no comma after the last one. Doing that for 300 rows in an editor is slow, and one missed quote breaks the query.

Paste the column instead. Three rows, 1042, 1043 and 1187, become IN (1042, 1043, 1187). All three are plain numbers, so they stay bare, which is right for a numeric column. Now paste O'Brien, Smith and 007. O'Brien is text, so every value is quoted, and its apostrophe is doubled, the SQL way to write a quote inside a string: IN ('O''Brien', 'Smith', '007'). The 007 is quoted too. A leading zero means it is a code, not a quantity, and writing it as the number 7 would match the wrong row.

Duplicates are removed by default, because a spreadsheet export often repeats an id, and the note under the result says how many went. Type a column name, such as customer_id, and it is written in: customer_id IN (...). That matters for the Oracle option. Oracle stops with error ORA-01795 when one IN list has more than 1,000 values, so with the option on, a list of 2,500 values becomes three lists of at most 1,000, joined with OR and wrapped in brackets: (customer_id IN (...) OR customer_id IN (...) OR customer_id IN (...)). The brackets keep the OR from mixing with the rest of your WHERE clause.

Quoting is the choice to think about. By default numbers are bare only when every value is a plain number. Turn on Quote every value when the column is a text type, such as a VARCHAR holding order numbers. Comparing a text column with a bare number can force the database to convert the column on every row, which stops it using an index and can fail outright on a row that is not a number. A quoted list compares text with text.

This is a tool for queries you write and run yourself. Doubling quotes makes each value a correct string literal, but application code should still pass values as query parameters, which the database driver handles safely. Very long lists have costs too. Above a few thousand values, loading them into a temporary table and joining it is usually faster than one giant IN, and some databases have limits on the total size of a statement. The tool also does not know your column types, so it cannot tell that a numeric-looking value belongs in a text column. That choice is yours.

Frequently asked questions

How are quotes inside a value handled?

Each single quote is doubled, the standard SQL way to write a quote inside a string. O'Brien becomes 'O''Brien'. This works in every major database.

Why are my numbers quoted?

Because at least one value is not a plain number, or has a leading zero. Mixing quoted and bare values in one list can make the database compare them as text or fail. Remove the odd value, or keep everything quoted.

What is the 1,000 limit?

Oracle allows at most 1,000 expressions in one IN list and gives the error ORA-01795 beyond that. Splitting into several IN lists joined with OR gets round it. Other databases have no fixed limit this low, but very long lists are still slow to parse.

Is this safe from SQL injection?

Doubling quotes makes each value a proper string literal, which is what an injection relies on breaking. Even so, use it for queries you run by hand. In application code, pass values as query parameters instead of building SQL text.

Are my values sent anywhere?

No. The list is built by JavaScript on this page, and nothing is uploaded.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.