How to convert CSV to JSON without losing leading zeros

Choose a delimiter, preserve codes as text and check quotes and rows before exporting a table.

Practical guideUpdated Approx. reading time: 3 min
On this page

Codes are not always numbers

A code such as 001 identifies an entry even though it contains only digits. Automatically converting it to the number 1 removes information another system may need. Kitavio preserves CSV cells as JSON strings.

The same rule avoids guessing date formats. A value such as 03/04/2026 may have different interpretations depending on its destination. Convert its type separately when you know the required format.

Delimiters and column names

The first row supplies JSON object keys. Names must be distinct and nonempty. Select comma, semicolon or tab according to the file; changing interface language does not change its delimiter.

Each row must contain as many cells as the header. An incomplete row produces an error to avoid shifting values to the wrong column. Empty fields remain empty strings.

Quotes and line breaks

A cell containing the delimiter must be enclosed in double quotes. Within a quoted cell, two quotes represent one literal quote. For example, "Says ""yes""" becomes Says "yes".

A line break within quotes belongs to the cell rather than beginning another contact. This is why simply splitting the file on commas or newlines is unreliable.

Reviewing a round-trip export

JSON to CSV accepts an array of objects and includes all keys found. Missing properties and null become empty cells. A nested object remains JSON within a cell rather than expanding into columns.

Formula protection adds an apostrophe to strings a spreadsheet might interpret as instructions. Keep it enabled when opening untrusted data; disable it only when those strings must remain literal.

  1. Download the fictitious table and choose its delimiter.
  2. Convert to JSON and check that code 001 remains a string.
  3. Inspect the note containing a comma and the one containing quotes.
  4. If converting back to CSV, check columns and records before importing into another program.

Criteria for reviewing and delivering the result

For a code table, define text columns before converting. An identifier with leading zeros can look numeric without representing a quantity. Import preserves cells as strings, but a later application may infer types again; inspect that stage separately. Include an empty cell, a delimiter containing note and a quoted value in a fictitious sample to test structure without exposing private records. These examples reveal parsing rules more clearly than a table containing only simple words.

On export back to CSV, inspect keys across objects and the representation of missing or nested properties. Choose formula protection according to the destination, particularly for spreadsheet use. Import with the correct delimiter and verify first row, last row, record count and a representative code. Keep the source with its types and context for resolving discrepancies. A round trip may retain ordinary values without preserving all bytes or structural distinctions. Define which properties matter to the exchange and document accepted output rather than assuming every readable result is complete for every system. The destination’s type handling is part of the workflow even when both conversions themselves succeed.

TRY IT YOURSELF

A table with codes and quotes

Download contacts.csv, open it in a text editor and paste its complete contents into CSV to JSON. Choose Comma and convert. Contacts are fictitious and column names are in English so you can check that they remain unchanged.

The first entry has code: "001" and note: "Hello, world". The second preserves quotes in Says "yes". No leading zeros are lost or extra columns created from the note’s comma.

Copy the JSON into JSON to CSV and compare cells in both tables. JSON whitespace may change without changing values.

View tool screenshot
CSV to JSON example using sample data
Kitavio screenshot in Chrome using the described example. Downloadable files contain fictitious data.