Excel to JSON: Differences, Edge Cases & Pitfalls

Turn Excel rows into a JSON array with header mapping and explicit typing for numbers, blanks and dates.

A worksheet becomes an array of objects, with row one as keys and each row as one object. The traps live in type inference: 001 turns into 1, IDs past 15 digits get float-damaged, and empty cells look identical to missing fields. Pin the column formats first.

Format Differences

AspectExcel (grid)JSON (object array)
StructureTwo-dimensional grid (rows x columns)Array of objects, nesting is native
KeysFirst row supplies column namesColumn names become keys; names with spaces need cleaning
TypesCell type plus display formatInferred number/boolean/string, no notion of formatting
Empty valuesEmpty cellnull or "" — different semantics, agree on one
NestingRequires extra sheets or repeated columnsNested objects and arrays directly
ArraysMultiple rows or a delimiter conventionNative arrays with explicit meaning
ReadabilityGood for humans to view and enterGood for programs and APIs
SizeIncludes styles and structure, largerData only, compact

Edge Cases

  • A column mixing text and numbers ("12" and 12) yields inconsistent types and breaks downstream validation — normalise the column first.
  • Column names with spaces or special characters are not valid identifiers; transliterate, underscore them or quote them.
  • Multi-row headers (merged cells) mean row one is not the real header — flatten the header first.
  • Blank rows are usually dropped; if they carried separation meaning it is lost entirely in JSON.

Common Pitfalls

  • Leading-zero identifiers become numbers, so 001 arrives as 1 and the write-back to the database is wrong.
  • Only the active worksheet is exported; the rest disappears silently.
  • Duplicate column names (two columns called "note") mean the later one wins — JSON objects cannot hold duplicate keys.
  • Numbers above 2^53 lose precision when parsed on the JS side; send big IDs as strings.

Related Tools