Many APIs (e.g. parseString, createCSVRecordAssembler, stream transformers) expose an outputFormat option so you can choose the most suitable record representation for your workload. This guide summarizes each format's behavior, strengths, and constraints.
| Format | Representation | Best for | ColumnCountStrategy support | Headerless (header: []) |
includeHeader |
Notes |
|---|---|---|---|---|---|---|
object |
Plain object { headerKey: value } |
JSON interoperability, downstream libs | fill, strict |
❌ | ❌ | Default output. Values are always strings. |
array |
Readonly array / named tuple | Maximum throughput, flexible schemas | All strategies (fill, keep, truncate, sparse, strict) |
✅ (with keep) |
✅ | Headerless mode requires outputFormat: "array" + columnCountStrategy: "keep". |
"object")fill mode, or rejected in strict.const assembler = createCSVRecordAssembler({
header: ["name", "age"] as const,
// outputFormat defaults to "object"
});
for (const record of assembler.assemble(tokens)) {
record.name; // string
}
"array")keep for ragged rows and sparse for optional columns.const assembler = createCSVRecordAssembler({
header: ["name", "age"] as const,
outputFormat: "array",
columnCountStrategy: "truncate",
});
const [row] = assembler.assemble(tokens);
row[0]; // "Alice"
object.array with the appropriate columnCountStrategy.For more details on column-count handling, see the ColumnCountStrategy guide.