SPARKPOND / GUIDE

How to Preserve Leading Zeros in CSV Files

Leading zeros disappear when identifiers are interpreted as numbers rather than text.

Problem symptoms

  • 000123 becomes 123.
  • Long IDs appear in scientific notation.

Why it happens

  • Spreadsheet auto-typing.
  • Automatic JSON number conversion.
  • Unsafe integer precision limits.

Example before and after

Before

customer_id
000123
9007199254740993

After

customer_id
"000123"
"9007199254740993"
Download example ↓

Procedure

  1. Keep identifier columns as text.
  2. Disable automatic numeric conversion.
  3. Preview JSON or XLSX typing.
  4. Verify the first and longest identifiers after export.
Convert CSV to JSON Online →

Common mistakes

  • Converting every digit-only column to number.
  • Opening and resaving in a spreadsheet before checking import settings.

Other possible solutions

  • Use the spreadsheet text-import setting for identifier columns.

Important limitations

  • A zero already lost by the source application cannot be inferred reliably.

Related guides

How to Convert Excel XLSX to CSV Without Excel

A browser can read XLSX values locally and serialize each selected sheet as a separate CSV.

CSV Formula Injection: Risks and Safe Exports

A spreadsheet may interpret cells beginning with =, +, -, @, tab or carriage return as formulas when a CSV opens.