How to use Convert CSV to JSON

  1. Paste your CSV into the Input CSV box, or click Select files to load it from a file.
  2. Under Input CSV Format, set the Column Separator, Field Quote and Comment Symbol. The defaults are a comma, a double quote and #.
  3. Under Conversion Options, check or uncheck Use Headers, Skip Empty Lines and Dynamic Types. All three are on by default.
  4. The Output JSON updates as you type. Click Copy to clipboard, or click Download to save it as a .json file.

Examples

CSV with a header row

name,age,city followed by John,30,New York produces [{"name": "John", "age": 30, "city": "New York"}].

Semicolon-separated values

With Column Separator set to ; the lines product;price and Apple;1.99 produce [{"product": "Apple", "price": 1.99}].

No header row

With Use Headers off, the lines 1,2 and 3,4 produce [[1, 2], [3, 4]]: each line becomes an array of values.

Good to know

  • With Use Headers on, the first line that is not blank or a comment provides the keys and every later line becomes an object. With it off, every line becomes an array of values.
  • Dynamic Types turns true and false (any letter case) into booleans, lowercase null into null, and numeric text into numbers. 007 becomes 7 and an empty cell becomes 0. Turn it off to keep every value as a string.
  • The input is split at line breaks, so a quoted field cannot span several lines. Quote characters are removed from values, a doubled quote inside a field is not kept as a literal quote, and spaces around each value are trimmed.
  • The separator is compared one character at a time, so it must be a single character. Typing \t (a backslash and a t) is not treated as a tab. Lines whose first non-space character is the Comment Symbol are skipped. The output is a JSON array indented with 2 spaces.
  • The conversion runs as JavaScript in your browser. The tool's code does not send your CSV over the network.

Frequently asked questions

What does Skip Empty Lines do?

Completely blank lines are always ignored. With Skip Empty Lines on, lines that contain only separators and spaces (such as ,,) are ignored too. With it off, such a line becomes a record with empty values, or 0s when Dynamic Types is on.

What happens if a row has fewer values than the header?

With Dynamic Types on, the tool shows an error instead of JSON. With it off, the missing keys are left out of that row's object. Values beyond the number of headers are dropped in both cases.

How do I keep leading zeros in IDs or zip codes?

Turn off Dynamic Types. When it is on, numeric text is converted to a number, so 01234 becomes 1234 and an empty cell becomes 0.

More CSV Tools