Images, documents & data · Learn

JSON or CSV? Choose a format that preserves the meaning of your data

Start here

CSV is useful for exchanging a flat table, but it needs agreed column meanings and import types. Keep JSON when nested structure and typed values matter, and test a representative sample in the actual receiving application.

ScopeTooliv converts arrays of JSON objects and delimited tables with headers, using pasted text or UTF-8 JSON, CSV, and TSV files up to 5,000,000 bytes. It does not infer a business schema, flatten nested arrays, or guarantee a lossless round trip.

Tools for this workflow

On this page 6

Start with what the recipient must preserve

Use CSV when the receiving program needs a flat table and you can agree on the columns and import rules. Keep JSON when the receiver needs nested records or the distinction between strings, numbers, booleans, and null. The receiving system’s supported formats come first.

RFC 8259 defines those different JSON values. RFC 4180 describes common CSV record and field conventions. A CSV file on its own does not tell the recipient that one column is an identifier, another is a count, and a blank means “not checked.”

Data to deliverStarting choiceRules to agree on
Repeated rows with the same columnsCSVHeaders, delimiter, encoding, import types
Values sent back into an APIJSONRequired properties, types, allowed ranges
Orders containing several items eachJSON or separate related tablesWhat one row represents and how records join
A table intended only for readingDocument tableUnits, rounding, notes, presentation

An identifier such as 0007 is not interchangeable with a numeric quantity of 7. Its leading zeros may be part of the identifier even though a spreadsheet could display both as a number.

Follow an actual round trip

The following invented records were passed through Tooliv’s conversion functions, then converted back. This check exercised the functions directly; it was not an Excel import or a browser download test.

[
  {"id":"0007","qty":2,"active":false,"note":null,"delivery":{"method":"courier"}},
  {"id":"0008","qty":0,"active":true,"delivery":null},
  {"id":"0009","qty":1,"active":false,"note":"","delivery":{"method":"pickup"}}
]

The CSV output is:

id,qty,active,note,delivery
0007,2,false,"","{""method"":""courier""}"
0008,0,true,"",""
0009,1,false,"","{""method"":""pickup""}"

After converting that CSV back to JSON, the first row becomes:

{
  "id": "0007",
  "qty": "2",
  "active": "false",
  "note": "",
  "delivery": "{\"method\":\"courier\"}"
}
ItemOriginal valueValue after the round trip
IdentifierString "0007"Same string
QuantityNumber 2String "2"
Active flagBoolean falseString "false"
DeliveryObjectA string containing JSON text
Note across the three rowsNull, absent property, empty stringEmpty string in every row

The result still has three records and five columns. Those counts do not establish that the original types and distinctions survived. A string containing the word false needs an explicit interpretation if the receiving application expects a boolean.

Give empty values an agreed meaning

In Tooliv’s JSON-to-CSV conversion, null and missing properties become empty cells. An empty string also produces an empty cell. CSV-to-JSON reads those cells as empty strings, so the round trip cannot tell you which original state applied.

If the distinction matters, preserve JSON or add an agreed status field before exporting. For example, a team might define note_status values such as not_checked, not_applicable, and provided. Those names are a proposed design, not a universal standard.

Writing the letters NULL into a CSV cell does not solve the problem without agreement. A receiver may treat that as literal text. A genuine zero also deserves its own check: zero items ordered is a different statement from an unknown quantity.

Decide what one row means before flattening

Tooliv gathers keys from the objects into CSV columns. Nested objects and arrays are stored as JSON text within a cell; it does not automatically create fields such as delivery.method or expand an item array into several rows.

If the receiver only needs the method, prepare a flat field such as delivery_method in the source. For an order containing several products, consider two tables:

TableOne row representsLink to the other table
OrdersOne complete orderorder_id
Order itemsOne product line in that orderorder_id and a line identifier

Suppose an order total is 30 currency units and contains three item lines. Repeating the total of 30 on every line, then summing that column, produces 90. This is an arithmetic consequence of the chosen row structure. The converter cannot decide whether your total belongs at the order level or the item level.

Define units as well. An amount column without a currency or an agreed unit can remain perfectly valid data while being misinterpreted.

Preserve identifiers before the first import

Tooliv’s CSV-to-JSON path keeps cell values as strings, including leading zeros. Another program may infer different types. Microsoft documents how Excel can remove leading zeros or change long numerical values, and describes importing identifier columns as text.

Long IDs should also be strings in JSON. Tooliv’s JSON-to-CSV converter rejects integers outside JavaScript’s safe integer range rather than accepting a silently rounded identifier. Once a prior application has already changed an ID, this converter cannot reconstruct the missing digits.

Use the Excel CSV guide when characters or column boundaries are wrong. Encoding fixes and type fixes address different problems.

Test the receiving contract with a small sample

Paste representative rows or open a UTF-8 JSON, CSV, or TSV file in the JSON and CSV converter. Confirm the comma, semicolon, or tab delimiter; the example above uses commas. Include a leading-zero ID, zero, false, an empty value, and a nested value. The preview shows at most ten data rows and twelve columns. Download or copy the full result, import it into the actual destination, and inspect both values and types.

Keep a short column definition alongside the file: name, meaning, unit, type, and empty-value rule. If the handoff also includes prose or tables for publication, use the document review workflow to check the final presentation separately from the underlying data.

Put it into practice

Apply what you have read to your own task.

Sources & review notes

This article uses the sources below and the tool’s current behavior. Check the linked official documentation for product-specific conditions and changes.

Find the cause of a problem and the next step to fix it.

More in Images, documents & data