csvjson
CSV to JSON converter
TLDR
Convert CSV to JSON array
SYNOPSIS
csvjson [options] file
DESCRIPTION
csvjson is part of csvkit that converts CSV files to JSON format. It supports various output formats including JSON arrays, keyed objects, newline-delimited JSON for streaming, and GeoJSON for geographic data.
By default, output is a JSON array of objects where each row becomes an object with column names as keys. The -k option creates a keyed object using a unique column's values as keys.
Type inference converts numeric and boolean values appropriately. The streaming mode outputs one JSON object per line, suitable for processing with tools like jq or for large files that shouldn't be loaded entirely.
PARAMETERS
FILE
CSV file to convert. Uses stdin if not specified.-i N, --indent N
Indentation level for pretty printing.-k COLUMN, --key COLUMN
Column to use as object keys (creates object instead of array).--stream
Output newline-delimited JSON (one object per line).--lat COLUMN
Latitude column for GeoJSON output.--lon COLUMN
Longitude column for GeoJSON output.-d CHAR, --delimiter CHAR
Field delimiter (default: comma).-e ENCODING, --encoding ENCODING
Input file encoding.--no-inference
Disable type inference (keep all values as strings).
CAVEATS
The -k option requires unique values in the key column. Large files may use significant memory without streaming mode. GeoJSON output requires valid latitude/longitude values. Type inference may misinterpret some values.
HISTORY
csvjson is part of csvkit, created by Christopher Groskopf in 2011. It enables easy conversion of tabular data to JSON, the dominant format for web APIs and JavaScript applications.
