{"id":20393049,"url":"https://github.com/aichbauer/node-convert-array-to-csv","last_synced_at":"2026-03-08T16:05:17.933Z","repository":{"id":31530951,"uuid":"128193011","full_name":"aichbauer/node-convert-array-to-csv","owner":"aichbauer","description":"Convert an array to a csv formatted string","archived":false,"fork":false,"pushed_at":"2023-01-06T02:04:02.000Z","size":243,"stargazers_count":31,"open_issues_count":14,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-26T06:43:15.091Z","etag":null,"topics":["array","converter","csv","list","nodejs","values"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aichbauer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-05T10:48:10.000Z","updated_at":"2024-05-28T08:17:10.000Z","dependencies_parsed_at":"2023-01-14T19:15:10.953Z","dependency_job_id":null,"html_url":"https://github.com/aichbauer/node-convert-array-to-csv","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aichbauer%2Fnode-convert-array-to-csv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aichbauer%2Fnode-convert-array-to-csv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aichbauer%2Fnode-convert-array-to-csv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aichbauer%2Fnode-convert-array-to-csv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aichbauer","download_url":"https://codeload.github.com/aichbauer/node-convert-array-to-csv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248565051,"owners_count":21125415,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["array","converter","csv","list","nodejs","values"],"created_at":"2024-11-15T03:47:09.174Z","updated_at":"2026-03-08T16:05:17.892Z","avatar_url":"https://github.com/aichbauer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# convert-array-to-csv\n\n[![npm](https://img.shields.io/npm/v/convert-array-to-csv.svg?style=flat-square)](https://www.npmjs.com/package/convert-array-to-csv)\n[![Travis branch](https://img.shields.io/travis/aichbauer/node-convert-array-to-csv/master.svg?style=flat-square)](https://travis-ci.org/aichbauer/node-convert-array-to-csv)\n[![Codecov branch](https://img.shields.io/codecov/c/github/aichbauer/node-convert-array-to-csv/master.svg?style=flat-square)](https://codecov.io/gh/aichbauer/node-convert-array-to-csv)\n\n\u003e Convert an array to a csv formatted string\n\n## Table of Contents\n\n* [Why?](#why)\n* [Installation](#installation)\n* [Functions](#functions)\n* [Usage](#usage)\n* [License](#license)\n\n## Why?\n\nI needed a simple way to download the data from a table component in a csv format.\n\n## Installation\n\n```sh\n$ npm i convert-array-to-csv -S\n```\n\nor\n\n```sh\n$ yarn add convert-array-to-csv\n```\n\n## Functions\n\nTake a look into the [usage section](#usage) for a detailed example.\n\n### convertArrayToCSV\n\n\u003e Note: you can also use the default export.\n\nThis function converts an array of objects, or an array of arrays into an csv formatted string.\n\n#### Syntax\n\nReturns a new string.\n\n```js\nconst csv = convertArrayToCSV(data, options);\n```\n\n##### Parameters\n\n* data: an array of arrays or an array of objects\n* options: a object\n  * holds two keys: header and separator\n  * **header**: and array with the name of the columns, default: `undefined`\n  * **separator**: the character which is the separator in your csv formatted string, default: `','`\n\n## Usage\n\nAn example how to use it.\n\n```js\nconst { convertArrayToCSV } = require('convert-array-to-csv');\nconst converter = require('convert-array-to-csv');\n\nconst header = ['number', 'first', 'last', 'handle'];\nconst dataArrays = [\n  [1, 'Mark', 'Otto', '@mdo'],\n  [2, 'Jacob', 'Thornton', '@fat'],\n  [3, 'Larry', 'the Bird', '@twitter'],\n];\nconst dataObjects = [\n  {\n    number: 1,\n    first: 'Mark',\n    last: 'Otto',\n    handle: '@mdo',\n  },\n  {\n    number: 2,\n    first: 'Jacob',\n    last: 'Thornton',\n    handle: '@fat',\n  },\n  {\n    number: 3,\n    first: 'Larry',\n    last: 'the Bird',\n    handle: '@twitter',\n  },\n];\n\n/*\n  const csvFromArrayOfObjects  = 'number,first,last,handle\\n1,Mark,Otto,@mdo\\n2,Jacob,Thornton,@fat\\n3,Larry,the Bird,@twitter\\n';\n*/\nconst csvFromArrayOfObjects = convertArrayToCSV(dataObjects);\n\n/*\n  const csvFromArrayOfArrays  = 'number;first;last;handle\\n1;Mark;Otto;@mdo\\n2;Jacob;Thornton;@fat\\n3;Larry;the Bird;@twitter\\n';\n*/\nconst csvFromArrayOfArrays = convertArrayToCSV(dataArrays, {\n  header,\n  separator: ';'\n});\n```\n\n## License\n\nMIT © Lukas Aichbauer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faichbauer%2Fnode-convert-array-to-csv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faichbauer%2Fnode-convert-array-to-csv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faichbauer%2Fnode-convert-array-to-csv/lists"}