How to use the csv column extractor
- Paste your CSV data into the text area.
- Enter the column indices (0,2,4) or header names (name,email) you want to keep, separated by commas.
- Choose the delimiter if your file uses semicolons, tabs, or pipes instead of commas.
- Toggle the header checkbox if the first row contains column names.
- Pick an output format: CSV, JSON, or a plain list.
How the parser works
The csv column extractor implements a strict RFC 4180 parser written in TypeScript with no dependencies. It reads the input character by character, tracking whether it is inside a quoted field. Inside quotes, a doubled double-quote ("") becomes a single quote in the output, and commas, newlines, and the delimiter itself are treated as literal data. Outside quotes, the chosen delimiter and line endings (CRLF, LF, or CR) separate fields and rows. This handles the full range of real-world CSV quirks: embedded commas, embedded line breaks, and escaped quotes.
For example, the line 1,"Smith, John",42 parses as three fields: 1, Smith, John, 42. The line "He said ""Hello""" parses as one field: He said "Hello".
Column selection
Columns can be specified by zero-based index (0, 1, 2…) or by header name when the header checkbox is on. Header matching is case-insensitive and ignores surrounding whitespace; an exact header match always wins over a number, so a header named 2024 is found by name. Only whole numbers are read as indices. You can mix indices and names in the same list, for example 0,email,2. Duplicate columns are preserved in the order you list them.
If a requested index is out of range for a given row, that row contributes an empty field for that column. If a header name is not found, the tool returns an error.
Ragged rows
Real CSV files often have rows with different column counts. The parser does not silently pad or truncate; it reports the actual number of fields found in each row. The result summary includes a Ragged rows count showing how many rows differ from the modal column count. This helps you spot data quality issues before downstream processing.
For instance, a file with a header of three columns but one data row containing four fields will show Ragged rows: 1. The extra field is still parsed and available if you select its index.
Output formats
CSV writes the selected columns with the same delimiter as the input. Quotes are added only when a field contains the delimiter, a quote, or a newline. JSON produces an array of objects when a header is present (keys are the selected header names) or an array of arrays otherwise. Plain list writes each selected value on its own line, row by row, which is handy for feeding into command-line tools.
Common use cases
- Extracting a subset of columns from a large export before loading into a spreadsheet or database.
- Converting a semicolon-delimited European CSV to a comma-delimited file with only the needed fields.
- Pulling a single column (e.g., email addresses) into a plain list for a mailing script.
- Inspecting ragged rows in a messy data dump to decide how to clean it.
Limits and edge cases
The parser runs in the browser and processes the entire input in memory. Very large files (hundreds of megabytes) may cause the tab to slow down or crash. For such files, use a streaming tool like csvkit or mlr on the command line. The tool does not support UTF-16 or other non-UTF-8 encodings; convert the file to UTF-8 first. It also does not interpret escape sequences like \n inside unquoted fields; those are treated as literal backslash-n.
Worked examples
| Example | Input | Result |
|---|---|---|
| Extract name and email by header | CSV data: id,name,email,city / 1,Alice,alice@example.com,New York / 2,Bob,bob@example.com,Los Angeles; Columns to extract: name,email; Delimiter: ,; First row is a header: yes; Output format: csv | Rows extracted: 2; Columns per row: 2; Ragged rows: 0 |
| Extract first and third columns by index | CSV data: red,green,blue / yellow,cyan,magenta / black,white,gray; Columns to extract: 0,2; Delimiter: ,; First row is a header: no; Output format: csv | Rows extracted: 3; Columns per row: 2; Ragged rows: 0 |
| Quoted fields with embedded commas and newlines | CSV data: id,description,price / 1,"Widget, small / blue",10.00 / 2,"Gadget, large / red",25.50; Columns to extract: description,price; Delimiter: ,; First row is a header: yes; Output format: json | Rows extracted: 2; Columns per row: 2; Ragged rows: 0 |
| Semicolon-delimited European CSV | CSV data: Vorname;Nachname;Ort / Hans;Müller;Berlin / Anna;Schmidt;München; Columns to extract: 0,2; Delimiter: ;; First row is a header: yes; Output format: list | Rows extracted: 2; Columns per row: 2; Ragged rows: 0 |
FAQ
Does this csv column extractor send my data to a server?
No. All parsing happens in your browser. Nothing is uploaded.
Can I use header names that contain commas?
Yes. Header names are matched after parsing, so a header like "Last, First" works fine. Just type it exactly as it appears, including the comma.
What happens if I select a column index that does not exist in some rows?
Those rows contribute an empty value for that column. The output will have the same number of rows as the input (minus the header if present).
Why does the ragged row count not match the number of rows I see?
The count compares each row's field count to the most common field count (the mode). Rows matching the mode are not counted as ragged.
Can I extract columns from a TSV file?
Yes. Choose "Tab (\t)" from the delimiter dropdown.
Does the tool handle Excel-style CSV with a BOM?
The parser strips a leading UTF-8 BOM (U+FEFF) if present, so Excel-saved UTF-8 CSVs work correctly.