Skip to content

How to convert an Excel sheet to JSON for an API

Prepare the header row, know how numbers, dates and empty cells come out, and get an array of objects your code can send.

By OpenAnyDoc ·

The short answer

Make the first row of the sheet hold the field names your API expects, then open the workbook in Excel to JSON. You get an array with one object per row, keyed by the header row, with numbers as numbers, true and false as booleans, dates as ISO 8601 text and empty cells as null. Check the values that matter to your API, then copy or download the .json file.

The shape you get

A sheet with the columns sku, name, price and inStock becomes a JSON array like this, indented with 2 spaces:

  • [ { "sku": "A-100", "name": "Notebook", "price": 4.5, "inStock": true }, { "sku": "A-101", "name": "Pen", "price": 1.2, "inStock": false } ]

Why an array of objects

An array of objects is what most APIs and apps accept for a list of records, and what most languages read straight into a list. If your API wants the list inside an object, such as { "items": [...] }, wrap it in your code or edit it in the JSON viewer. Rows with nothing in them are skipped, so blank lines between blocks of data do not become empty objects.

Header row to keys

Every key comes from the header cell above it, exactly as written apart from spaces at the start and end. "Unit price" stays "Unit price", with its space and capital letter. APIs usually expect names like unitPrice or unit_price, so rename the header cells to match the API before converting; it is the one change that saves the most work later. Two rules cover the gaps:

  • An empty header cell becomes its column letter, such as C.
  • A header that appears twice gets a number: the second Price becomes Price_2, the third Price_3.

Numbers and text

A cell that holds a number becomes a JSON number, using the stored value, not the format Excel shows. That matters in a few places:

  • A cell shown as 15% becomes 0.15, and a price shown as 1,200.00 becomes 1200.
  • A code stored as a number loses its leading zeros: 00123 shown through a number format becomes 123. Store such codes as text in Excel (format the column as Text, then type them again) and they arrive as "00123".
  • Excel keeps only 15 significant digits in a number, so long reference numbers should be stored as text before they are typed in, or they are rounded in the workbook itself.
  • TRUE and FALSE become true and false. Text stays a string, even if it looks like a number.

Dates

A date cell becomes ISO 8601 text such as "2026-01-05T00:00:00.000Z", which every programming language can read back. The day is kept as the calendar day in the cell, whatever your computer's time zone. If your API wants only the date, take the first 10 characters (2026-01-05) in your code. A date typed as text, for example in a column formatted as Text, stays exactly as it was typed, so check that a date column holds real dates.

Empty cells and formulas

An empty cell becomes null, so every object has the same keys, which is what most APIs and schema checks expect. If your API wants missing fields left out instead, remove the null values in your code. A formula becomes its value; the formula itself, formatting, charts and images are not in the JSON.

Which sheet

Excel to JSON converts the first sheet. For another sheet, open the workbook in the Excel viewer, click the sheet's tab, then click Convert at the top and choose Convert to JSON. The viewer is also a quick place to rename header cells first: the conversion takes the sheet with your edits.

Before you send it to the API

The result opens in the JSON viewer, where you can read it as a tree or a table, fix values and minify it. A few next steps help when the JSON feeds code:

  • Write a schema from the result with JSON Schema, and check later files against it.
  • Get TypeScript interfaces for the records with JSON to TypeScript.
  • If the sheet holds customer names, emails or phone numbers and the JSON is test data, mask them first with Mask data.

Questions?

Write to support@openanydoc.com with the header row and one made-up row of the sheet, and the JSON your API expects (no personal data).