csv guide
Keep Leading Zeros When Converting CSV to JSON
Preserve identifiers such as 00127 with a reproducible CSV sample, expected JSON and checks for upstream spreadsheet conversion.
Published September 7, 2026 by SOLVEOZA Editorial
Quick answer
Treat identifiers as text throughout the workflow. SOLVEOZA CSV to JSON preserves cell values as strings, including leading zeros. If a spreadsheet already changed 00127 to 127, the converter cannot know which digits were lost.
A code is not necessarily a number
A product identifier uses digits to name an item. Its width may be meaningful, so 00127 and 127 need not identify the same thing. A quantity is different: padding does not usually change the amount it represents.
Decide which columns are identifiers before importing. Record that decision in the handoff rather than expecting another program to infer it from a few rows.
Inspect the original CSV before conversion
Open a copy in a plain-text editor. If 00127 is still present in the raw text, those characters are available to preserve. If it already says 127, investigate the upstream export first.
This invented inventory sample includes three codes and one deliberately empty code. An empty field is not the digit zero.
code,label
00127,Notebook
00008,Pencil
01000,Folder
,UnassignedConvert without guessing types
In CSV to JSON, choose Comma and First row as headers. Convert the sample and compare it with the expected result. Cell values remain strings: the first code is quoted as 00127 rather than stored as the number 127.
Check that there are four rows. Inspect every code before passing the output onward, and do not convert numeric-looking identifiers merely to make the JSON shorter.
[
{
"code": "00127",
"label": "Notebook"
},
{
"code": "00008",
"label": "Pencil"
},
{
"code": "01000",
"label": "Folder"
},
{
"code": "",
"label": "Unassigned"
}
]Find the stage that changed the value
Compare the original export, the spreadsheet import and the final JSON. If the raw CSV retained the zeros but a later export lost them, the spreadsheet step is the place to investigate. Re-running JSON conversion cannot reverse an upstream edit.
| Stage | Value | Meaning |
|---|---|---|
| Raw CSV | 00127 | Original characters available |
| JSON output | "00127" | Text identifier preserved |
| Numeric interpretation | 127 | Width information discarded |
| Display-only mask | 00127 on screen | Verify exported text; appearance alone is not evidence |
When Excel is part of the workflow
Microsoft documents text import and formatting options for preserving zeros. In supported Excel versions, use Data → From Text/CSV and inspect the column type during import. Do not assume that opening a CSV automatically preserves identifiers. Menus vary by version and platform.
Check the exported file in a text editor after the spreadsheet step. A custom cell format changes appearance; it does not establish what was in the original data. For long identifiers, check all digits as well. The instructions here reference Microsoft documentation, not an interactive test of every Excel version.
Recover from the source, not a guessed width
Padding 127 to five places is justified only when an authoritative rule says the code has five digits. Without that rule, 0127, 00127 and 000127 are different possible originals.
Request a text-preserving export or compare with a trusted source list. Keep identifiers separate from quantities, and document whether the receiving application expects empty strings, missing fields or null values.
Methodology
- Use four synthetic rows, including three padded product codes and an empty code.
- Run the existing CSV converter with comma and first-row settings.
- Compare row count and values with the expected independent object.
Limitations
- Lost identifiers cannot be reconstructed from this conversion.
- Spreadsheet instructions depend on version and platform.
- Receiving applications may require different field types or null handling.
Sources
Original SOLVEOZA examples and guidance checked against the references below. Sources explain the rules; they are not endorsements of this site.
- Keeping leading zeros and large numbers (accessed 2026-09-07)
FAQ
Do quoted CSV values protect zeros in every spreadsheet?
No. Importers may infer types. Verify raw values and the chosen import type.
Does the converter infer numbers?
Current SOLVEOZA CSV conversion keeps cell values as strings. Check the receiving application before deliberately converting selected fields.
What happens to an empty code?
In this fixture the empty cell becomes an empty string, not zero or null.
Can I restore deleted zeros?
Only with a trustworthy source or explicit format rule. The converter does not guess missing width.