Easily generate csv downloads of your json data.
npm install json-to-csv-exportA function to easily generate csv downloads of your json data. ✨



https://json-to-csv-export.coston.io
- Create a csv download from json data
- Lightweight
- Easy to use
- Optional filename
- Optional header names
Install with npm:
``sh`
npm i json-to-csv-export
`jsx
// import jsonToCsvExport from "json-to-csv-export";
() => {
const mockData = [
{
ID: 1,
"First Name": "Sarajane",
"Last Name": "Wheatman",
Email: "swheatman0@google.nl",
Language: "Zulu",
"IP Address": "40.98.252.240",
},
{
ID: 2,
"First Name": "Linell",
"Last Name": "Humpherston",
Email: "lhumpherston1@google.com.br",
Language: "Czech",
"IP Address": "82.225.151.150",
},
];
return (
);
};
`
`jsx
// import jsonToCsvExport from "json-to-csv-export";
() => {
const mockData = [
{
id: 1,
firstName: "Sarajane",
lastName: "Wheatman",
email: "swheatman0@google.nl",
language: "Zulu",
ip: "40.98.252.240",
},
{
id: 2,
firstName: "Linell",
lastName: "Humpherston",
email: "lhumpherston1@google.com.br",
language: "Czech",
ip: "82.225.151.150",
},
];
const headers = [
{ key: "id", label: "Identifier" },
{ key: "firstName", label: "First Name" },
{ key: "lastName", label: "Last Name" },
{ key: "email", label: "Email Address" },
{ key: "language", label: "Language" },
{ key: "ip", label: "IP Address" },
];
return (
);
};
`
`typescript`
interface HeaderMapping {
label: string;
key: string;
}
| # | Property | Type | Requirement | Default | Description |
| --- | --------- | ----------------------------- | ----------- | ------------ | --------------------------------------------------------------------------- |
| 1 | data | Record | required | | array of objects |string
| 2 | filename | | optional | "export.csv" | The filename. The .csv extention will be added if not included in file name |string
| 3 | delimiter | | optional | "," | fields separator |string[]
| 4 | headers | , HeaderMapping[]` | optional | | provided data object keys |
Please help provide good data faster! Submit any issues and/or make a pull request!