From semicolon CSV to JSON, keeping leading zeroes

Work through a fictional CSV with quotes and a multiline cell: change its delimiter, inspect records, and convert to JSON while keeping string values.

Fictional files for reproducing the steps

Source example
id;name;note;amount;active
0007;Atelier Demo;"Kit; taille M";12,50;false
0042;Studio Exemple;"Message ""merci""
Livraison mardi";0;true
0105;Boutique Fictive;"Paris, France";;false

1. Start with a file you can check

A semicolon-separated export can contain another semicolon inside a description, quotation marks, and even a line break inside one cell. Replacing every semicolon with a comma would damage those values. This walkthrough uses three fictional records so you can check each step before trying your own export.

Download example-semicolon.csv and open it in a text editor. Its five columns are id, name, note, amount, and active. The identifiers are 0007, 0042, and 0105. The second record’s note contains a real line break, so the file has more visible lines than data records.

2. Change the separator, keeping the values

Copy the entire file into the CSV delimiter converter. Select Semicolon as the original separator, then run the conversion. You must choose the separator yourself; the output always uses commas between columns. Copy the result and compare it with expected-comma.csv.

The value 12,50 becomes a quoted field in the comma-separated output, but its decimal comma stays unchanged. Kit; taille M keeps the semicolon inside its text. In the second record’s note, the quotation marks around merci are doubled for CSV, and the line break stays within that same cell.

3. Inspect the records before moving on

Paste the result into the CSV explorer and select Comma. Click “Explore CSV” to build the table. You should see three records and five columns. Search for 0042: only one row should remain. Check its identifier and note. The table may visually collapse the embedded line break into a space; the filtered export lets you check that the underlying value is preserved.

Try Export filtered CSV, then use the generated download link. Compare that file with expected-filtered-0042.csv. Clear the search to show all three rows again. The download contains only matching records, so use the complete delimiter-converter result for the next step if you want all three records in JSON.

4. Convert to JSON with string values

Paste the complete comma-separated result into CSV to JSON. Compare the output with expected.json: there should be three objects. Each header becomes a property name. The identifier "0007" stays a string with its leading zeroes; "false", "true", "0", and "12,50" also remain strings. The empty amount cell in the third record becomes "", not null.

The line break appears as the escape sequence \n in the JSON text. When an application reads that JSON, it represents a line break within the value. This conversion does not infer numbers, dates, or booleans. Make any later type conversion deliberately, according to the receiving application’s requirements.

Before using your own export

Headers must be unique, and every record must have the same number of fields. Invalid quotation marks are rejected. The explorer accepts up to 2,000,000 characters and displays the first 500 matching records; its export includes all filtered records. These limits are not a promise about performance on every device.

Conversion does not neutralize formulas. Before opening untrusted data in a spreadsheet, review cells beginning with =, +, -, @, a tab, or a line break. CSV quoting alone does not make them safe. Use appropriate import settings and check text columns. Spreadsheet behavior varies; this walkthrough does not promise universal Excel compatibility.

Frequently asked questions

Can the delimiter converter produce semicolon-separated output?

No. It reads comma-, semicolon-, or tab-separated input and produces comma-separated CSV.

Why did my spreadsheet remove the leading zeroes?

The spreadsheet may interpret a column as numbers. Check the text file and choose a text import for identifiers, then verify the result in your application.

Can I convert just the searched record to JSON?

Yes. Export the filtered CSV from the explorer with Comma selected, then paste its contents into CSV to JSON. In this example, searching for 0042 produces one object.

References

Continue with another exercise