List to SQL IN
Turn a column of values into a SQL IN list, like IN ('a', 'b'), or into one comma-separated line, and split a line back into a list. Quotes are escaped and duplicates removed. Runs in your browser.
Worked example
The apostrophe in O'Brien is doubled, the repeated line is dropped, and accented text passes through unchanged.
O'Brien Zoë smith O'Brien
IN ('O''Brien', 'Zoë', 'smith')Common mistakes
Pasting untrusted values into production SQL
Escaping quotes isn’t a defence against SQL injection. For anything that runs in an app, use parameterized queries; this tool is for quick ad-hoc queries.
Quoting numbers
IN ('1', '2') compares text with numbers, which some databases convert and others reject, and it can stop an index being used. Use no quotes for numeric IDs.
An empty IN list
IN () isn’t valid SQL, so the tool gives no output until there’s at least one value.
Hidden spaces
Values copied from spreadsheets often end in a space or tab, and 'abc ' won’t match 'abc'. Keep Trim on.
How it works
- 1
Paste one value per line
Copy a column from a spreadsheet, a query result or a log. To go the other way, pick Split line and paste a comma-separated line or an IN list.
- 2
Choose quotes and layout
Single quotes for text, none for numbers (the tool suggests it when every value is a number), or double quotes. Choose whether to wrap the list in IN ( … ) and how many values go on each line.
- 3
Copy it into your query
Copy the result or download it. Values are trimmed, empty lines skipped and duplicates removed unless you turn those off.
Questions
- How are apostrophes handled?
- With Escape quotes on, a quote inside a value is doubled, which is how standard SQL writes it: O'Brien becomes 'O''Brien'. Backslashes are left as they are.
- Single or double quotes?
- Use single quotes for text values; that works in every major database. In standard SQL and PostgreSQL, double quotes name columns and tables instead, so "abc" means a column called abc. MySQL treats double quotes as strings unless ANSI_QUOTES is set.
- Is there a limit on how many values an IN list can have?
- The tool has no limit, but databases do. Oracle allows at most 1,000 expressions in one IN list. For long lists, a temporary table or a join is often faster and clearer.
- Can it turn an IN list back into lines?
- Yes. Pick Split line and paste the list. A surrounding IN ( … ) is ignored, quoted values may contain commas, and with Remove quotes on, 'O''Brien' comes back as O'Brien.
- Is my list uploaded?
- No. It’s converted in this tab and never sent anywhere.