⬇️ json-to-csv-export

A function to easily generate csv downloads of your json data. ✨

npm package version   npm downloads   code style: prettier

Live Demo

https://json-to-csv-export.coston.io

Features

Install

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>

Example Usage

// 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 (
    <button onClick={() => jsonToCsvExport({ data: mockData })}>
      Download Data
    </button>
  );
};

Properties

#PropertyTypeRequirementDefaultDescription
1data[]requiredarray of objects
2filenamestringoptional"export.csv"The filename. The .csv extention will be added if not included in file name
3delimiterstringoptional","fields separator
4headersstring[]optionalprovided data object keysList of columns that will be used in the final CSV file. Recommended for large datasets!

Migration from version 1.x to 2.x

migration.md

Contributing

Please help provide good data faster! Submit any issues and/or make a pull request!