Data Format Converter · Tutorial

How to convert a semicolon CSV to JSON without losing zeros

5 min readbeginnerUpdated

Spreadsheets set to many European locales export CSV with semicolons, and product codes such as 0007 often lose their zeros when a converter treats them as numbers. This tutorial converts such a file to clean JSON, with prices as numbers, codes kept as text and empty cells as null.

What you need

  • The Data Converter, set to CSV → JSON
  • A CSV export, or the sample product list from the Try it button

Steps

  1. Paste or open the CSV

    Paste the data into the left box or open the file. The sample is a product list separated by semicolons, with IDs like 0007, prices written as 18.5, an empty stock cell and a name that contains a semicolon inside quotes.

    product_id;name;category;price;stock;launch_date
    0007;Bento box;Kitchen;18.5;120;2025-03-01
    0045;"Tea set; 6 cups";Tableware;45;18;2025-09-09
  2. Let the separator be detected

    Leave Separator on Detect. The tool sees the semicolons and splits the columns correctly. The quoted "Tea set; 6 cups" stays in one cell because the semicolon is inside quotes.

  3. Keep column names and type detection on

    With First row is column names ticked, every row becomes an object with keys like product_id and price. With Detect numbers and true/false ticked, 18.5 and 120 become numbers.

  4. Check the codes and empty cells

    Look at the output. "product_id": "0007" is still text with its leading zeros, because turning it into the number 7 would lose information. The empty stock cell for the chopstick set has become "stock": null, which most programs treat as no value.

  5. Choose the output style

    Keep 2 spaces for a readable file, or choose Minified to save space when the JSON goes into an API request or a database seed script.

  6. Save the JSON

    The note above the boxes says 4 rows. Press Download to save converted.json, or Copy to paste it into your code.

Try it yourself

Opens the Data Format Converter with this tutorial's sample loaded.

Try it now

Common mistakes

Decimal commas
Some exports write prices as 18,5. Number detection only reads a dot as the decimal point, so those prices stay as text. Replace the commas, or convert the values in your program.
Turning detection off by accident
With Detect numbers and true/false off, every value is a string, including prices. Turn it on unless your program expects text.
A file without a header row
If the first line is data, untick First row is column names. Otherwise the first product becomes the key names.

Next steps

Go back to the Data Format Converter, or keep going with one of these:

Tutorial · 5 min · beginner

How to read a pyproject.toml file as JSON

Convert a Python pyproject.toml to JSON to see how its dotted tables nest, then pull out dependencies and tool settings with any JSON tool.

FAQ

How do I keep dates as dates?

JSON has no date type, so dates stay as text like 2025-03-01. This ISO format is easy for any language to parse.

Can I convert a tab-separated file?

Yes. Detect recognises tabs too, or choose Tab in the Separator menu.