A function to easily generate csv downloads of your json data. ✨
https://json-to-csv-export.coston.io
- Create a csv/json download from data
- Convert json/csv data
- Lightweight
- Easy to use
- optional filename
Install with npm:
npm i json-to-csv-export
Or load from a CDN:
<script src="https://cdn.jsdelivr.net/npm/json-to-csv-export"></script>
import csvDownload, { jsonDownload, jsonToCsv, csvToJson } from 'json-to-csv-export'
...
<button onClick={() => csvDownload(jsonData)}>
Download CSV Data
</button>
...
<code>
{jsonToCsv(jsonData).data}
</code>
...
<button onClick={() => jsonDownload(csvData)}>
Download JSON Data
</button>
...
<code>
{csvToJson(csvData).data}
</code>
# | Argument | Type | Requirement | Default | Description |
---|---|---|---|---|---|
1 | data | object |
required |
null |
string or object |
2 | filename | string |
optional |
"export.[csv|json]" | The complete filename |
3 | delimiter | string |
optional |
"," | field separator |
# | Argument | Type | Requirement | Default | Description |
---|---|---|---|---|---|
1 | data | object |
required |
null |
string or object |
2 | delimiter | string |
optional |
"," | field separator |
Singular function to convert and download JSON to CSV data. This is shown in an example above.
Singular function to convert and download CSV to JSON data. This is shown in an example above.
Convert CSV data into JSON data.
Returns
{ data:string, error:string }
Convert JSON data into CSV data.
Returns
{ data:string, error:string }
Please help provide good data faster! Submit any issues and/or make a pull request!