json2csv-lite
Tiny, dependency-free JSON to CSV converter for Python.
- No external dependencies
- Supports list-of-dicts and dict-of-lists
- Optional nested-dict flattening
- Works with files or strings
Install
pip install json2csv-lite
Usage
from json2csv_lite import json_to_csv
data = [
{"name": "Ali", "age": 30},
{"name": "Sara", "age": 25},
]
csv_text = json_to_csv(data)
print(csv_text)
# name,age
# Ali,30
# Sara,25
Write directly to a file:
json_to_csv(data, output="people.csv")
Flatten nested objects:
data = [{"id": 1, "meta": {"lang": "py", "level": 3}}]
print(json_to_csv(data, flatten=True))
# id,meta.lang,meta.level
# 1,py,3
From a JSON string:
from json2csv_lite import json_string_to_csv
json_string_to_csv('[{"a": 1}, {"a": 2}]')
API
json_to_csv(data, output=None, *, delimiter=",", include_header=True, flatten=False)
| Parameter | Type | Default | Description |
|---|---|---|---|
data |
list[dict] or dict[str, list] |
– | Input data |
output |
str, Path, or None |
None |
Optional output file path |
delimiter |
str |
"," |
CSV delimiter |
include_header |
bool |
True |
Include header row |
flatten |
bool |
False |
Flatten nested dicts with dot notation |
json_string_to_csv(json_string, output=None, **kwargs)
Convenience wrapper around json_to_csv.
License
MIT
Release files for json2csv-lite 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| json2csv_lite-0.1.0.tar.gz | 4.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| json2csv_lite-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.3 kB
Release files / json2csv_lite-0.1.0.tar.gz
| Download URL | json2csv_lite-0.1.0.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
718b04a53c46728fa1c95f73e4862e52620c1f4733d03d81cce44fb4623f4428
|
|
BLAKE2b-256 checksum How to use checksums |
09de09c074fe6635e26b9586d2b59a26909327d90aa785ba296acaf8d8d47c31
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.
Transparency logRelease files / json2csv_lite-0.1.0-py3-none-any.whl
| Download URL | json2csv_lite-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d0412e3c6aea972df61b7a7321a0e9937b5840d2035e5a1e8390697e7751d43e
|
|
BLAKE2b-256 checksum How to use checksums |
0ffe93ab474803a9812171f82c99b7f2a53428013ca0fb3b00d1cfa39a1e2d7b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.
Transparency log