

It can be 'line' to parse into CSVlines, 'array' to write a complete JSON array downstream downstreamFormat - option to set what JSON array format is needed by downstream.nullObject - boolean to indicate whether we keep null or not.alwaysSplitAtEOL - Boolean to indicate if we split each line by the end of line character.Index.js const csvFilePath = 'person.csv' const csv = require('csvtojson') (async () => will parse the foo field as a number. Person.csv first_name,last_name john,smith jane,smith We can retrieve a CSV from a file and convert it to JSON or we can get the CSV from a string and do the same thing.įor instance, we can get a CSV from a file and convert it to JSON as follows: This package works with both the browser and Node.js. We can run the following to install it: npm i csvtojson The csvtojson is available as an NPM module. In this article, we’ll look at how to use the csvtojson module to convert CSV to JSON. Converting CSV to JSON is a task that’s being done a lot as we need to use CSV in our apps.
