Skip to content
OddsockLocal
Local
Source text
ItemQuantity
Notebook12
Pencil4
3 wordsRuns in this browser. Nothing is uploaded.

How to use

  1. Paste a CSV with a header row.
  2. Read the JSON array. One object per data row.
  3. Check codes with leading zeros. They stay strings.
  4. Check bare numbers. They become JSON numbers.

What is CSV to JSON?

A CSV row becomes one object, the header cells become keys, and the values are typed. true, false, and null become those JSON values. A number without a leading zero becomes a number. A token with a leading zero, such as 001, stays a string, which is how an identifier survives. Empty cells become empty strings.

Read more

The sheet name, amount, code with a first row "A, Inc.", 2, 001 produces an object whose name is A, Inc., whose amount is the number 2, and whose code is the string 001. The two following Bob rows, amount 10 and a blank code, become two objects with code as an empty string. That is three objects, not a deduped list. The analyzer would have called the code column numeric and shown 1. This page does not.

The result is pretty JSON. Nested cells are not created, because CSV has no nesting. The other direction, JSON to CSV, flattens nested objects into dotted columns.

Use cases

  • A developer turning an export into fixtures for a test.
  • A student checking that 001 did not become the number 1.
  • An integrator keeping a company name that contains a comma.
  • An analyst comparing this typed array with the analyzer's numeric reading of the same code column.
  • Someone preparing records for JSON to SQL.

A quoted company, a padded code, two Bobs

name,amount,code then "A, Inc.",2,001 then Bob,10, then Bob,10,

Three objects. The first has name A, Inc., amount 2, and code "001". Each Bob has amount 10 and code "".

Why use Oddsock

Typed values mean the JSON matches what a script expects from the sheet, with 12 as a number beside the item name.

Related tools

Using this tool

A leading zero is not part of the JSON number grammar used here. 2 has no leading zero, so it becomes a number. The analyzer parses 001 as 1. These pages disagree on purpose.