Parsing And Displaying CSV Files In jQuery - csv.js

Parsing And Displaying CSV Files In jQuery - csv.js
File Size: 112 KB
Views Total: 7310
Last Update:
Publish Date:
Official Website: Go to website
License: MIT

csv.js is a jQuery based CSV parser that parses your CSV files and converts the CSV strings into JavaScript arrays and objects for further use. Ideal for dynamically generating data tables and data charts/graphs from CSV files. Supports both browser and node.js.


$ npm install jquery-csv --save

How to use it:

1. Insert the main JavaScript file csv.js after jQuery JavaScript library.

<script src="" 
<script src="src/jquery.csv.js"></script>

2. The JavaScript to parse a single line of CSV data into an array of values.


3. The JavaScript to parse CSV data into a JavaScript 2D (two-dimensional) array.


4. The JavaScript to parse CSV data into an array of objects.


5. Possible plugin options.

$.csv.functionName(csv, {

  // separator

  // delimiter

  // shows headers


6. Event handlers.

$.csv.functionName(csv, {

  onPreParse: function(){},

  onParseEntry: function(){},

  onParseValue: function(){},

  onPostParse: function(){},


7. Use the plugin in node.js.

var fs = require('fs');
var $ = jQuery = require('jQuery');

var sample = 'sample.csv';
fs.readFile(sample, 'UTF-8', function(err, csv) {
  $.csv.toArrays(csv, {}, function(err, data) {
    for(var i=0, len=data.length; i<len; i++) {


v1.0.8 (2019-12-13)

v1.0.4 (2019-06-21)

  • Bugfixed

v1.0.0 (2019-05-03)

  • fixed a bug where onParseValue was mistakenly being applied to the toObjects header fields
  • fixed a bug where onPreParse wasn't updating the input csv string
  • fixed errors to call throw Error instead of throw new Error
  • fixed bug where that broke the Node.js callback convention when an empty options object was supplied

v0.9.1 (2019-05-01)

  • Cleanup


  • v0.8.12

This awesome jQuery plugin is developed by typeiii. For more Advanced Usages, please check the demo page or visit the official website.