A simple library to convert JSON to CSV and vice versa. Designed to be lightweight and easy to use, json-csv-converter
leverages powerful libraries to handle the conversion processes efficiently.
To install json-csv-converter
, run the following command in your project directory:
npm install json-csv-converter
After installing json-csv-converter
, you can use it in your project by requiring the library and calling its functions.
const { jsonToCsv } = require('json-csv-converter');
// Your JSON array
const jsonArray = [
{ name: "John Doe", age: 30, email: "john@example.com" },
{ name: "Jane Doe", age: 25, email: "jane@example.com" }
];
// Path to save the CSV file
const outputPath = './output.csv';
// Convert and save the CSV
jsonToCsv(jsonArray, outputPath);
const { csvToJson } = require('json-csv-converter');
// Path to your CSV file
const csvPath = './input.csv';
// Path to save the JSON file
const outputPath = './output.json';
// Convert and save the JSON
csvToJson(csvPath, outputPath);
Contributions to json-csv-converter
are welcome! Please follow these steps to contribute:
- Fork the repository.
- Create a new branch for your feature (
git checkout -b feature/AmazingFeature
). - Commit your changes (
git commit -m 'Add some AmazingFeature'
). - Push to the branch (
git push origin feature/AmazingFeature
). - Open a Pull Request.
Distributed under the ISC License. See LICENSE
for more information.
- Thanks to the authors of
json2csv
andcsvtojson
for their excellent libraries that made this project possible.