Convert CSV to JSON without losing ID precision
CSV exports from databases and spreadsheets are everywhere — and most generic converters mangle them in two specific ways:leading zeros disappear (00123 becomes123) and big numbers lose precision(9007199254740993 can't survive JavaScript's number type). If those columns are IDs, the converted JSON is quietly wrong.
Why it happens
JSON has separate types for strings and numbers. A naive converter guesses "looks numeric → emit a JSON number." That guess is wrong for identifiers: 00123 as a number is 123, and integers above 2^53 lose their last digits entirely. IDs aren't quantities — they're labels, and labels belong in quotes.
How the ToolDeck converter handles it
The CSV ↔ JSON Converter treats every CSV field as a string by default — preserving00123, 9007199254740993, and empty cells exactly as written. If you explicitly ask it to emit numbers, it warns you about values that would lose precision rather than silently corrupting them. Going the other direction (JSON → CSV), values that can't round-trip safely are reported instead of exported wrong.
CSV rules worth knowing
- Quoted fields can contain commas, newlines, and escaped quotes (
"") — the converter handles all three. - BOM — Excel adds a byte-order mark to CSV exports; it's stripped automatically.
- Duplicate column names produce a warning, not silent data loss.
- Formula-looking cells (
=,+,-,@starts) get flagged when exporting to CSV, since spreadsheet apps may execute them — an opt-out exists if your data is trusted.
When strings aren't enough
If your downstream system genuinely needs JSON numbers, convert IDs and quantities separately — or accept that values above 9007199254740991 must stay strings no matter what. The converter's warnings exist precisely for this decision; read them before overriding.
For one-off inspection of a single value, theJSON Formatter validates syntax and preserves large numeric literals exactly.