ModernCalcs

CSV Data Type Converter

name
Auto-detected: string
age
Auto-detected: number
score
Auto-detected: number
active
Auto-detected: boolean
joined
Auto-detected: date
name,age,score,active,joined
Alice,30,95.5,true,2021-01-15
Bob,25,88,yes,2020-06-03
Charlie,35,72.0,false,2019-11-20

Auto-detection shows the probable type per column. Select a conversion per column and the output will apply it to every data row.

CSV Data Type Converter: Fix Types Before Import or API Submission

CSVs exported from spreadsheets often store numbers as quoted strings: '42' instead of 42. Boolean values come out as 'Yes'/'No' or '1'/'0'. Column names may be inconsistently cased. This tool auto-detects the probable type of each column and lets you choose a conversion to apply before your data reaches a database, REST API, or data pipeline.

Formula
Column: age → auto-detected: number Input: "30","25","35" Output: 30,25,35 (unquoted numbers) Column: active → auto-detected: boolean Input: yes,no,1,0 Output: true,false,true,false

Type detection scans all non-empty values in each column. A manual override always takes precedence over auto-detection.

The Type Problem in CSV

All CSV values are strings at the file level. When a spreadsheet exports '42' with quotes, or simply writes 42 without, many CSV parsers still treat both as strings. Database importers may default to VARCHAR for everything. JSON converters may output {"age": "30"} instead of {"age": 30}. Fixing types before import saves ALTER TABLE statements and API contract mismatches.

Boolean Normalization

The Boolean conversion handles the common legacy patterns: 1/0 from old databases, Yes/No from business spreadsheets, True/False from application exports — all normalized to lowercase true/false. This is particularly important for REST APIs and GraphQL schemas that expect a JSON boolean type, not a string.

Case Transformations

UPPERCASE, lowercase, and trim are available for string columns. UPPERCASE is useful for normalizing country codes, currency codes, and other fixed-vocabulary columns. Trim removes leading/trailing whitespace — often needed when a spreadsheet adds padding. These are applied to the text representation without changing the column's quoted status.

Available Conversions

  • Number: strip quotes, parse integer/float
  • Boolean: yes/no/1/0/true/false → true/false
  • UPPERCASE: transform all text values
  • lowercase: transform all text values
  • Trim: strip leading/trailing whitespace
  • String: no conversion (passthrough)

Frequently Asked Questions

Why do CSV columns need type conversion?

CSV stores everything as text — the number 42 is stored the same way as the string '42'. When CSV is imported into a database, converted to JSON for an API, or loaded into a data analysis tool, the receiving system may not correctly infer types. Databases may store numbers as text VARCHAR instead of INT, and boolean values like 'yes' may not be recognized as booleans. Explicit type conversion before import fixes these problems.

What does the Number conversion do?

The Number conversion strips surrounding quotes from numeric cells and parses the value: '42' becomes 42, '95.5' becomes 95.5. This matters when the CSV will be fed to a system that reads column type from the value format — JSON parsers will then serialize these as numbers rather than quoted strings.

What boolean values are recognized?

The Boolean conversion recognizes: true, yes, 1 (case-insensitive) → true; and false, no, 0 → false. Other values are left unchanged. This handles the common case where older systems export boolean values as 1/0 or Yes/No strings that need to be normalized to true/false for modern APIs.

How is auto-detection calculated?

Auto-detection scans all non-empty values in each column. If all non-empty values parse as numbers, the column is typed as number. If all values match a boolean pattern (true/false/yes/no/1/0), it's boolean. If values match common date patterns, it's date. Otherwise it's string. Auto-detection is a hint — you control the actual conversion per column.