Preserve leading zeros when converting CSV/JSON (no upload)

TL;DR: Fix delimiter/quotes first, then convert CSV to JSON locally (no upload).

How to preserve leading zeros (IDs, zip codes) when moving between CSV, JSON, and Excel—without uploading your data.

Why leading zeros disappear

Excel aggressively treats values as numbers. When it guesses a column is numeric, 00123 becomes 123.

If you export that back to CSV, the zeros are permanently lost unless you kept the original text representation.

Best practice: keep IDs as strings

IDs, SKUs, and zip codes should usually be strings. JSON supports strings natively, and CSV can represent strings by quoting values.

When converting CSV to JSON, ensure the values remain strings if leading zeros matter.

  • Treat ID-like fields as strings (even if they look numeric).
  • Avoid Excel auto-format by importing as text when possible.

Validate before export

Convert a small sample and verify a few IDs at the top and bottom of the dataset.

Once the JSON is correct, you can safely copy or download it for downstream usage.

Excel-proof workflow (recommended)

The safest approach is to preserve the original text representation as long as possible, and only open the data in Excel after you’ve validated that IDs remain strings.

If Excel already removed zeros, go back to the source export (or the original CSV) and re-import with explicit “text” column types.

  • CSV → JSON: keep ID-like fields as strings.
  • JSON → CSV: ensure IDs are quoted if needed for spreadsheet import.
  • Excel import: set the ID column to Text before loading data.

Trust note: All processing happens locally in your browser. Files are never uploaded.

FAQ

Can JSON store numbers with leading zeros? Numbers don’t keep leading zeros. Use strings instead.

Is this safer with no-upload tools? Yes—sensitive identifiers stay on-device.

Local verification snippet

Run a quick local check before export/convert:

import csv
from io import StringIO

sample = text[:50000]  # keep first chunk for fast local triage
rows = list(csv.reader(StringIO(sample)))
print('rows:', len(rows), 'columns(first row):', len(rows[0]) if rows else 0)
Privacy & Security
All processing happens locally in your browser. Files are never uploaded.

Quick fix checklist

  • Reproduce the error on a minimal input.
  • Check type/format and field mapping.
  • Apply the smallest safe fix.
  • Validate on production-like payload.

Next pages to check

Closest crawled pages without impressions yet. Added to speed first-impression conversion.

neighbor csharp go json cannot unmarshal bool into field user id type int troubleshootinneighbor python go json cannot unmarshal string into field payload user type string runbneighbor csharp go json cannot unmarshal array into field payload items type float64 worneighbor csharp go json cannot unmarshal array into field payload items type float64 worneighbor csharp go json cannot unmarshal array into field payload items type float64 worneighbor csharp go json cannot unmarshal array into field payload items type float64 worneighbor csharp go json cannot unmarshal array into field payload items type int workfloneighbor csharp go json cannot unmarshal array into field payload items type int workfloneighbor csharp go json cannot unmarshal array into field payload items type int workfloneighbor csharp go json cannot unmarshal array into field payload user type string checkneighbor csharp go json cannot unmarshal array into field payload user type string checkneighbor csharp go json cannot unmarshal array into field payload user type string workfneighbor csharp go json cannot unmarshal array into field payload user type string workfneighbor csharp go json cannot unmarshal array into field payload user type string workfneighbor csharp go json cannot unmarshal array into field payload user type string workfneighbor csharp go json cannot unmarshal array into field payload user type string workfneighbor csharp go json cannot unmarshal array into field user createdat type time time neighbor csharp go json cannot unmarshal array into field user createdat type time time