Home CSV to JSON

CSV to JSON

Paste CSV or open a file. The first row becomes the keys. Numbers and true/false are typed, and dotted columns plus repeated rows fold into objects and arrays.

JSON

Why this exists

A sheet exported from a spreadsheet is awkward to paste into code because of commas and quotes. A comma or a line break inside a field still has to stay one value.

Columns written as customer.name, and rows that repeat one order, fold back into objects and arrays that an API can take.

  1. 01How to use it

    Paste CSV or choose a file. The delimiter is whichever of comma, tab, semicolon, or pipe appears most on the first row.

    When the encoding differs, pick UTF-8, UTF-16, Windows-1252, Shift-JIS, GBK, Big5, or EUC-KR. Auto reads a BOM and otherwise uses UTF-8.

  2. 02What you get

    The example has two orders. Alice’s keyboard and mouse gather into one order’s items, and the tags become an array.

    The result is JSON indented by two spaces. Copy it or download it as result.json.

    EnteredTwo orders

    Rows 2 orders
    Nested customer, tags, items
    Output JSON
  3. 03Worth knowing

    A line break or comma inside a field stays one value when the field is quoted. An unclosed quote names the line.

    A very large sheet can slow the browser, so parsing stops at 5MB. A file that holds passwords or personal data also stays on this device.

Questions

QDoes the file get uploaded?
ANo. Pasted text and the file you choose become JSON only in this browser.
QWhy does a number stay text?
AA value such as 007, or one outside the safe integer range, stays a string. Only true and false become booleans.
QWhat are dots and repeated rows?
Acustomer.name becomes the name inside a customer object. Rows that share the earlier cells gather into an array such as items.
QWhich files can I open?
ACSV and TSV. Auto follows a BOM and otherwise reads UTF-8. Japanese, Chinese, Western European, and Korean encodings can be chosen too.

How this page works it out

The first row of the table is read as headers. A dotted name such as parent.child becomes a nested object, and rows that repeat the same parent are gathered into an array.

The words true and false become booleans, and ordinary numbers become numbers. A value with a leading zero stays a string, and an integer bigger than 2^53-1 stays a string, so those digits are not shortened.

You can read UTF-8, UTF-16, EUC-KR, Windows-1252, Shift-JIS, GBK, Big5, ISO-8859-1, or let the page choose the encoding from the BOM. An unclosed quote is an error. The download is named result.json.

The table file is parsed only in this browser. The JSON is built on this page before you download it, and the file bytes are not sent out to be converted.

  • # csv
  • # json
  • # spreadsheet
  • # converter