SQL IN Clause Generator

Paste a list of values, one per line, to build a SQL IN or NOT IN clause with quoting and a column name, splitting long lists into groups of 1,000.

Why split: Oracle refuses an IN list of more than 1000 values (ORA-01795), so the groups start at 1000. PostgreSQL, MySQL and SQL Server set no fixed number, but a list of many thousands is slow to parse, and SQL Server can refuse one outright.

Result
IN ('apple', 'banana', 'cherry')
IN ('apple', 'banana', 'cherry')

Turn a list into a SQL IN clause

Copy a column of values out of a spreadsheet, a log file, or a text document, paste them one per line, and this tool assembles a ready-to-run IN (...) clause you can drop straight into a WHERE statement. Blank lines are ignored and every value is trimmed of surrounding whitespace, so messy pasted data still produces a clean, comma-separated list. The output updates live as you type and copies with one click. Layout starts on “One line”; “One value per line” and “Several values per line” put real line breaks into the clause itself, so the copy and the downloaded .sql file keep them.

Quoting, escaping, and column names

Toggle Quote values on for text columns and each value is wrapped in single quotes; leave it off for numeric columns to emit bare numbers like IN (1, 2, 3). Single quotes inside a value are safely escaped by doubling them, so O'Brien becomes 'O''Brien' instead of breaking your query. Set Database to “MySQL, MariaDB” and backslashes are doubled as well, because those read a backslash as an escape and a value ending in one would leave the string open; a server set to NO_BACKSLASH_ESCAPES wants the default, “PostgreSQL, SQL Server, SQLite, Oracle”. Add an optional column name to get a complete predicate such as status IN ('active', 'pending'). Tick Exclude values (NOT IN) for the opposite predicate, and Split large lists into multiple IN() groups when a database caps the list — Oracle stops at 1,000 — to break it into several clauses of at most that many values (1,000 by default, and you can change it). Splitting needs a column name, because the groups are combined into one predicate: joined with OR for IN, and with AND for NOT IN.

Frequently asked questions

How are single quotes inside a value handled?

When quoting is on, any single quote inside a value is escaped by doubling it, following standard SQL string rules. For example O'Brien is output as 'O''Brien', which is safe to paste into most SQL databases.

Should I quote values for numeric columns?

No. Turn off Quote values so numbers are emitted bare, like IN (1, 2, 3). Turn it on only for string, date, or other text columns that require single quotes.

Do the values have to be one per line?

No. Choose what separates them — new lines, commas, tabs, semicolons, spaces or any of these — and opening a CSV or TSV file picks the right one.

Can I lay the list out over several lines, or write it for MySQL?

Yes. Layout starts on “One line”; “One value per line” and “Several values per line”, with a “Values per line” field, put the line breaks into the clause itself, so they copy and download too and a list in a reviewed .sql file stays readable in a diff. A split list lays out every group the same way. Database starts on “PostgreSQL, SQL Server, SQLite, Oracle”, which doubles single quotes only; “MySQL, MariaDB” doubles backslashes as well, so a value ending in a backslash cannot leave the string open.