Home › Developer Tools › SQL IN Clause Generator

SQL IN Clause Generator

Paste a column of IDs, emails or codes copied from Excel, a log or another query. You get a ready WHERE … IN (…) condition with quotes escaped, duplicates removed and long lists split for databases with limits.

Last updated:

Values in clause0
Duplicates removed0
Treated as—
IN lists0
Advertisement
Advertisement

How to use the SQL IN Clause Generator

  1. Paste your values into the left box, one per line or separated by commas or tabs.
  2. Type the column name (e.g. customer_id) and choose IN or NOT IN.
  3. Pick the database so quoting and escaping match it, and set a maximum list size if it has a limit.
  4. Check the options: remove duplicates, sort, strip existing quotes, or wrap the result in your own query.
  5. Press Generate IN Clause, read any warnings, then copy the SQL or download it as a .sql file.

IN list syntax by database

DatabaseText valueIdentifier quotingNotes
Standard SQL / SQLite'O''Brien'"order"Double the single quote; double quotes mean a column or table name.
MySQL / MariaDB'O''Brien', backslash doubled`order`Backslash is an escape character unless NO_BACKSLASH_ESCAPES is set.
PostgreSQL'O''Brien'"order"Also accepts col = ANY (ARRAY[…]), handy with array parameters.
SQL Server'O''Brien' or N'Ünïcode'[order]Use the N prefix for NVARCHAR columns with non-Latin text.
Oracle'O''Brien'"ORDER"Maximum 1,000 values per list (ORA-01795); split longer lists.

Long lists, NULLs and other traps

  • Chunks are joined with OR for IN and with AND for NOT IN. id NOT IN (…) OR id NOT IN (…) would match almost every row, which is a classic bug when splitting lists by hand.
  • Leading zeros matter. ZIP codes, phone numbers and SKUs such as 00721 must stay quoted; as numbers they lose the zeros and stop matching.
  • Type mismatches slow queries down. Comparing a VARCHAR column with unquoted numbers (or a number column with quoted strings) can force a conversion on every row and skip the index. Match the quoting to the column type.
  • Duplicates are harmless but noisy. They do not change the result, but removing them keeps the statement shorter and easier to review.
  • Prefer parameters in application code. This tool is for ad-hoc queries, reports and scripts. In an application, pass the values as bound parameters or an array to avoid SQL injection.

Frequently asked questions

How do I turn an Excel column into a SQL IN list?

Copy the cells in Excel and paste them into the input box. Each cell arrives on its own line, so the tool splits on new lines, trims spaces, removes duplicates and wraps everything in an IN ( … ) list with the right quotes. Type your column name to get the full condition, for example customer_id IN (1001, 1002, 1003).

Should values in an IN clause be quoted?

Text values must be in single quotes, such as 'abc'. Numbers can be written without quotes when the column is numeric. Leave quotes on codes with leading zeros like 00721; unquoted they become the number 721. Auto-detect only drops the quotes when every value is a plain number without leading zeros.

How do I escape an apostrophe in a SQL string?

Standard SQL escapes a single quote by doubling it, so O'Brien becomes 'O''Brien'. That works in PostgreSQL, SQL Server, Oracle, SQLite and MySQL. MySQL also treats the backslash as an escape character by default, so the tool doubles backslashes when you choose MySQL. Double quotes are for identifiers in standard SQL, not for string values.

Is there a limit on the number of values in an IN list?

Oracle allows at most 1,000 expressions in one list and raises ORA-01795 above that. Other databases have no fixed number but are limited by statement length and parameter limits, and huge lists parse slowly. Set Max values per list to 1,000 and the tool splits the list into several IN lists joined with OR, which Oracle accepts.

Why does NOT IN return no rows when the list contains NULL?

x NOT IN (1, 2, NULL) means x <> 1 AND x <> 2 AND x <> NULL, and any comparison with NULL is unknown, so the whole condition is never true. Likewise IN (NULL) never matches NULL rows. With the NULL option on, the tool removes NULL from the list and adds an explicit IS NULL or IS NOT NULL test instead.

When should I use a temporary table instead of a long IN list?

For tens of thousands of values a join is usually faster and easier on the query planner: load the values into a temporary table (or a table-valued parameter in SQL Server, or = ANY with an array parameter in PostgreSQL) and join to it. IN lists are ideal for quick lookups, ad-hoc reports and a few hundred to a few thousand values.

Is my data sent to a server?

No. The list is processed by JavaScript in your browser, so customer IDs, emails and other values never leave your computer.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

SQL Formatter & BeautifierFormat, beautify or minify SQL queries for MySQL, PostgreSQL and more.CSV to SQL ConverterConvert CSV to SQL CREATE TABLE and INSERT statements for MySQL, PostgreSQL, SQLite or SQL Server.Comma SeparatorTurn a column of lines into a comma separated list and back, with any delimiter.Remove Duplicate LinesDelete duplicate lines from any list, ignoring case or spaces, keep first or last, and sort.JSON to Excel ConverterTurn JSON into a styled .xlsx spreadsheet; nested arrays become their own linked sheets.JSON to CSVConvert JSON data to CSV for spreadsheets.CSV to JSONConvert CSV data to JSON with live preview.Excel to CSVConvert XLSX spreadsheets to CSV.CSV ViewerOpen a CSV or TSV file as a sortable, filterable table.Excel Viewer (XLSX / XLS)Open XLSX, XLS and ODS spreadsheets in your browser without Excel.Line Ending ConverterConvert text and files between CRLF, LF and CR line endings.Markdown to HTMLConvert Markdown to clean HTML with a live editor.XML to JSONConvert XML to JSON with validation.Text Encoding ConverterDetect and convert text file encodings like UTF-8, UTF-16 and Latin-1.JSON ViewerExplore JSON as a collapsible tree, search keys and values and copy any node's path.TTF to WOFF2 ConverterConvert TTF and OTF fonts to WOFF2 or WOFF and get a ready @font-face CSS snippet.Chmod CalculatorConvert Linux file permissions between checkboxes, octal (755) and symbolic (rwxr-xr-x) notation.JSON to TypeScriptGenerate TypeScript interfaces or types from JSON, with nested types and optional fields.Morse Code TranslatorTranslate text to Morse code and back, then play it as sound or a blinking light, or save a WAV.HTML Table GeneratorBuild HTML tables in an editable grid with styles, header rows, CSV import and live preview.Hex to Text ConverterConvert hex to text and text to hex with UTF-8 support and space, 0x, \x or comma formats.JSON to XML ConverterConvert JSON to well-formed XML with attributes, arrays and pretty print.JSON to YAML ConverterConvert JSON to clean YAML as you type, with indent, quoting and sort options.YAML to JSON ConverterConvert YAML to pretty or minified JSON, with errors pinned to the exact line.HTML to Markdown ConverterTurn HTML or pasted rich text into clean Markdown with tables and live preview.Markdown Table GeneratorBuild Markdown tables in a grid or paste from Excel/CSV, with alignment and preview.JSON ValidatorCheck JSON with the exact line and column of each error, fix tips and one-click auto-fix.Image to Base64Convert images to Base64 data URIs, CSS backgrounds and HTML img tags in your browser.Base64 to ImagePaste a Base64 string or data URI to preview, identify and download the image.JSON CompareCompare two JSON documents and see every added, removed and changed path.Hex to DecimalConvert hex to decimal instantly with steps and signed mode.Decimal to HexConvert decimal to hex instantly with steps and signed mode.Binary to DecimalConvert binary to decimal instantly with steps and signed mode.Decimal to BinaryConvert decimal to binary instantly with steps and signed mode.Two's Complement CalculatorDecimal to two's complement binary and back for 4-64 bits, with invert-and-add-1 steps.XML to CSV ConverterConvert XML to CSV: detects repeating records, flattens nested data, pick your columns.CSV to XML ConverterConvert CSV to well-formed XML with custom root and row names, escaping and pretty print.TOML to JSON ConverterConvert TOML to JSON and JSON to TOML with a full v1.0 parser and clear error lines.TypeScript to JavaScriptConvert TypeScript or TSX to clean JavaScript instantly: strip types, keep or compile JSX.XML to YAML ConverterConvert XML to clean YAML with attributes, text nodes, lists and exact error lines.YAML to XML ConverterConvert YAML to pretty, well-formed XML with custom root, attributes and array item tags.Boolean Algebra SimplifierSimplify boolean expressions or minterm lists to minimal SOP and POS with Quine-McCluskey steps.Compare Excel FilesCompare two Excel spreadsheets cell by cell, highlight changes and export a diff report.CSV CleanerClean messy CSV in one click: trim spaces, drop empty rows and columns, fix headers, dedupe.CSV VLOOKUP ToolJoin two CSV or Excel files on a key column like VLOOKUP, with left, inner and full joins.Remove Duplicates in ExcelFind and remove or highlight duplicate rows in XLSX or CSV files by the columns you choose.GeoJSON ViewerView GeoJSON on a map, inspect and edit properties, validate against RFC 7946 and export.GPX ViewerOpen GPX tracks on a map with distance, elevation profile, moving time, speed and splits.JSON Repair ToolFix broken JSON automatically: trailing commas, quotes, comments, truncated data, with a diff.Karnaugh Map SolverSolve 2–6 variable K-maps: click cells or enter minterms to get the minimal SOP or POS with groups.Merge Excel FilesCombine XLSX, XLS and CSV files into one workbook or append all rows into a single sheet.Parquet File ViewerOpen Apache Parquet files in your browser: schema, rows, filters and CSV or JSON export.Query CSV with SQLRun SQL on CSV, Excel, JSON and Parquet files in your browser with DuckDB. Join and export.Online Serial MonitorTalk to Arduino, ESP32 and USB serial devices in your browser: log, send, plot and save.Split Excel FileSplit an Excel sheet into several files by row count or by each value in a column, as ZIP.SQL Create Table GeneratorDefine columns, keys, defaults and indexes; get CREATE TABLE SQL for MySQL, Postgres and more.SQL Online CompilerRun SQL queries online on SQLite with sample databases, a result grid, CSV export and .db save.SQL to ER DiagramPaste CREATE TABLE statements and get an entity-relationship diagram with keys and links.XML to XSD GeneratorGenerate an XML Schema (XSD) from sample XML: types, occurrences, attributes and namespaces.XML ValidatorCheck if XML is well-formed, see the exact line and column of each error and pretty-print it.Wildcard Mask CalculatorConvert a subnet mask or CIDR to a wildcard mask for ACLs and OSPF, with range and binary.CSV to VCF ConverterConvert a contacts CSV into a vCard (.vcf) file, mapping columns to name, phone, email and more.CSV to YAML ConverterConvert CSV rows to a YAML list of mappings with type inference and delimiter detection.Endianness ConverterSwap byte order of 16, 32 and 64-bit hex values and see big- and little-endian integers and floats.Excel to SQL ConverterTurn an Excel sheet into CREATE TABLE and INSERT statements for MySQL, PostgreSQL, SQLite or SQL Server.Excel to VCF ConverterTurn an Excel contact list into a vCard .vcf file for iPhone, Android, Google or Outlook.File to C ArrayConvert any file into a C or C++ byte array header, like xxd -i, with const and PROGMEM options.Image to C ArrayConvert images to monochrome, RGB565 or RGB888 C arrays for OLED, LCD and TFT displays.
See all 129 Data & File Format Converters →