SQL IN-list builder
Turn a column of values into a quoted, comma-separated list ready to paste into a SQL WHERE … IN (…) clause.
Input
Output
What it does
Paste a column of values, such as IDs or email addresses copied from a spreadsheet, and get them back quoted and separated by commas, ready to drop into WHERE column IN (…). Blank lines are skipped and spaces around each value are removed.
How to use it
- Paste your values into the input pane, one per line.
- Choose the quotes: single for text, none for numbers.
- Set the rest to suit the query:
- Wrap in ( ) adds the parentheses, so the result can follow
INdirectly. - Remove duplicates leaves each value in once.
- Escape quotes in values doubles any quote inside a value so the SQL stays valid.
- Values per line breaks a long list across lines. Leave it at 0 for one line.
- Wrap in ( ) adds the parentheses, so the result can follow
- Press Copy and paste the list into your query.
With no quotes chosen, the tool tells you if any value is not a number, since unquoted text would not be valid SQL.
Questions
Should I use single or double quotes?
Single quotes for text values. That is standard SQL and works in PostgreSQL, MySQL, SQL Server, Oracle and SQLite. Double quotes mean a column or table name in standard SQL, so use them only if your database treats them as strings, as MySQL does by default. Choose no quotes for numbers.
What happens to a value with an apostrophe in it, like O'Brien?
With "Escape quotes in values" on, the apostrophe is doubled: 'O''Brien'. That is how SQL writes a quote inside a quoted string, and without it the query would break at the apostrophe.
Does this make my query safe from SQL injection?
It makes a list you can paste into a query you are writing by hand. It is not a substitute for bound parameters in application code. If the values come from users and the query is run by a program, pass them as parameters instead of building the text of the query.
Is there a limit to how many values an IN list can have?
The tool has no limit, but databases do. Oracle before version 23 allows 1,000 values in one IN list, and SQL Server can run out of resources with many thousands. For a very long list, load the values into a temporary table and join to it.
Are the values I paste sent anywhere?
No. The list is built in your browser. Nothing is uploaded or stored, which matters when the column is customer emails or account IDs.