TsWorks Tools
All tools (39)

CSV to TypeScript Definition

Generate TypeScript types for the rows of a CSV file.

Delimiter
Declare as

Off keeps every value a string, which preserves leading zeros.

Paste CSV or TSV. Quoted fields, embedded commas and newlines are handled.

CSV to TypeScript Definition

Paste a CSV export and get a TypeScript interface describing one row. The header row gives the field names; the data underneath gives the types.

The types come from the data, not the header

Every row in the file is read, not just the first, so a column that is numeric in some rows and empty in others comes out asnumber | null rather than as whichever the first row happened to be. That is the single most common thing a first-row-only generator gets wrong.

Everything in a CSV is text until you say otherwise

A CSV file has no types - 42 and "42" are the same bytes. The convert numbers and booleans checkbox is therefore what decides your types: leave it on and numeric columns become number, turn it off and every field isstring, which is the honest answer if you are typing the parse result rather than the parsed data.

Related tools