CSV to JSON by API without losing leading zeros
Most CSV to JSON converters guess types and turn 00501 into 501. How the JustAPI converter keeps values as text by default, and when to turn type inference on.
ZIP code 00501 becomes 501. Phone number 0044 7700 900123 becomes 4.47709E+12. Product code 1E5 becomes 100000. These are the classic CSV import bugs, and they all come from the same choice: guessing types.
Strings by default
The CSV and Excel to JSON API keeps every CSV value as a string unless you ask otherwise:
curl https://api.justapi.tech/v1/data/to-json \
-H "Authorization: Bearer ak_live_..." \
-H "Content-Type: application/json" \
-d '{"source": {"url": "https://files.example.com/contacts.csv"}}'
{ "format": "csv", "sheets": [ { "name": "csv", "columns": ["name", "zip"], "row_count": 2,
"rows": [ { "name": "Ana", "zip": "00501" }, { "name": "Bo", "zip": "10001" } ] } ] }
A CSV file has no types; every value is text. Turning text into numbers is a decision that belongs to you, because only you know that zip is a code and amount is a number.
When to turn inference on
Set infer_types: true when your columns are real numbers and flags. The converter is careful even then:
- Only canonical numbers become numbers:
42,-3.5,0.25. Values with leading zeros like007, exponents like1E5, or thousands separators stay strings. trueandfalsebecome booleans.- Empty cells become
null.
If one column needs numbers and another must keep its zeros, leave inference off and convert the numeric columns in your code.
Delimiters and encodings
The delimiter is detected from the file: comma, semicolon (common in European exports), tab or pipe. Set delimiter to override. The encoding is detected too; files from older Excel versions in Latin-1 come out with accents intact. Set encoding if you know it.
Headers
With header: true (the default), the first row gives the keys. Empty or repeated header names are made unique. With header: false, each row is an array.
Size
Up to 2 million cells per file. The JSON is returned inline in result.data when it is 1 MB or smaller, and is always downloadable from result.url.
Cost
$0.004 per file at the first tier. Try your own CSV in the free CSV to JSON tool.