columnCountStrategy controls how the parser handles rows whose column counts differ from the header. The available strategies depend on the output format and whether a header is known in advance.
| Strategy | Short rows | Long rows | Object | Array (explicit header) | Array (header inferred) | Headerless (header: []) |
|---|---|---|---|---|---|---|
fill |
Pad with "" |
Trim excess columns | ✅ | ✅ | ✅ | ❌ |
strict |
Throw error | Throw error | ✅ | ✅ | ✅ | ❌ |
keep |
Keep as-is (ragged rows) | Keep as-is | ❌ | ✅ | ✅ | ✅ (mandatory) |
truncate |
Keep as-is | Trim to header length | ❌ | ✅ | ❌ (requires header) | ❌ |
sparse |
Pad with undefined |
Trim excess columns | ❌ | ✅ | ❌ (requires header) | ❌ |
fill (default)"", enabling consistent string-based models.strictkeepheader: []) enforces keep.truncatesparsefill, but pads missing entries with undefined. This is useful when you want to distinguish between missing and empty values.strict.fill (object default).keep (array output).truncate (array output with header).sparse (array output with header).Pair this guide with the Output Format Guide to decide which combination best fits your workload.