How to Convert a List to a SQL IN Clause
You have a list of IDs, emails, or names and you need them formatted as a SQL IN clause. Doing it manually means adding quotes and commas one by one, which takes time and is easy
to get wrong at item 47. Paste the list here and it formats in one shot.
Convert your list now. Free, no account needed.
Open List Format Converter →How to do it
- Paste your list into the converter. One value per line. Names, emails, IDs, whatever you have.
- Select SQL IN Clause from the format dropdown.
- Choose your quote style. Single quotes for strings. No quotes for integers. More on this below.
- Copy the output. It includes the parentheses, so you get the whole
('value1', 'value2', ...)block ready to paste.
Your full query ends up looking like this:
SELECT * FROM users WHERE email IN ('alice@example.com', 'bob@example.com', 'carol@example.com') Which quote style to use
- Single quotes: use for strings, emails, names, codes, any text data. Single quotes are the SQL standard for string literals and work in MySQL, PostgreSQL, SQLite, and SQL Server.
- No quotes: use for integers and numeric IDs. Quoting a number as a string can cause an implicit type cast that bypasses indexes on numeric columns.
- Double quotes: generally avoid for string literals. In most databases, double quotes are for identifiers (column and table names), not values.
Values that contain apostrophes
If your data includes apostrophes (names like "O'Brien" or "it's"), they'll break
a single-quoted SQL string. The fix is to escape them by doubling the apostrophe: O'Brien becomes O''Brien in SQL.
Do a find-and-replace on your list before converting. For a handful of values it's quick. For a large dataset with many apostrophes, handle it on the database side with parameterised queries instead.
When the list is too long for IN
The IN clause works fine for dozens or a few hundred values. Once you're
in the thousands, query planners start struggling. For large sets, load your values into a temporary
table and use a JOIN instead. It's faster, the query plan is more
predictable, and you're not hitting any parameter limits.
Need other formats from the same list?
JSON array, Markdown bullets, HTML list, CSV row: 21 formats, same tool.
Frequently Asked Questions
How do I convert a list to a SQL IN clause?
Should I use single or double quotes in a SQL IN clause?
How do I handle a list of numbers in SQL IN?
WHERE id IN (1, 2, 3) is correct. Quoting them as strings ('1', '2', '3') may cause an implicit type cast that hurts index performance.What if my values contain apostrophes, like O'Brien?
O'Brien becomes O''Brien. Do a find-and-replace on your list first.What's the maximum number of values in a SQL IN clause?
Does this work for PostgreSQL, MySQL, and SQL Server?
IN (...) syntax is the same across all major databases. Single quotes for string literals work in all of them.Can I convert the result back to a plain list?
Can I also get a JSON array from the same list?
["apple", "banana", "cherry"] from the same input. See How to Convert a List to a JSON Array for number detection and formatting options.