Back to Features
Feature

Automatic Type Detection

We figure out your column types so you don't have to.

When you upload a CSV, csv-api inspects every column and assigns the most specific type that fits the data. Numeric columns become integers or floats. Date strings become dates. True/false columns become booleans. The rest stay strings.

What it does

Automatic type detection means your API knows the difference between '32' the number and '32' the string. Filter operators behave correctly — _gt and _lt are available on numeric and date columns but not on strings. Sorting respects numeric order instead of lexicographic order. The 'age' column sorts 2, 9, 30, 100 instead of 100, 2, 30, 9. All of this happens automatically the moment your file is uploaded — no schema definition required.

How it works

  1. 1

    Sample the file

    When you upload a file, we read the column headers and a sample of rows to figure out what kind of data lives in each column.

  2. 2

    Assign the most specific type

    Each column gets the narrowest type that fits all of its values: integer, float, boolean, date, or string. We err on the side of strings if the data is mixed.

  3. 3

    Power smart query operators

    Filter operators automatically respect the detected type. Numeric comparisons, date ranges, and string matching all just work.

See it in action

customers.csv
name,age,balance,is_active,signup_date,city
Ada Lovelace,36,1234.56,true,2024-03-15,Portland
Grace Hopper,42,9876.50,true,2023-11-02,Seattle
Alan Turing,41,250.00,false,2024-01-20,Manchester
Linus Torvalds,29,4200.75,true,2024-06-08,Helsinki

Detected types

Column Type
name string
age integer
balance float
is_active boolean
signup_date date
city string

Why it matters

  • No manual schema work

    Skip the step where you define column types in a separate config or migration. Upload, confirm, query.

  • Correct sorting and filtering

    Numbers sort numerically. Dates sort chronologically. Comparison operators only appear where they make sense.

  • Reflected in your docs

    Detected types show up in the auto-generated OpenAPI spec and Swagger UI for every dataset, so consumers know exactly what they're working with.

The problem it solves

Treating every column as a string is the cheap way out and it breaks the moment a user tries to ask 'show me records where age is greater than 30.' Type detection means csv-api gets the column types right at upload time — once — instead of forcing every consumer of your data to do it again.

Common use cases

  • Sorting numeric columns the way humans expect (2, 9, 30, 100 not 100, 2, 30, 9)

  • Filtering date columns by range without writing custom parsers

  • Building forms whose input types match the underlying column

  • Surfacing accurate column types in the OpenAPI spec for codegen

Try Automatic Type Detection for yourself

Create a free csv-api account, upload a file, and see your API live in under a minute.

We use essential cookies to keep you logged in. No tracking or analytics. Privacy policy