Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/donatj/csvtomarkdowntable
Simple JavaScript/Node.js CSV to Markdown Table Converter
https://github.com/donatj/csvtomarkdowntable
csv javascript markdown markdown-table
Last synced: 6 days ago
JSON representation
Simple JavaScript/Node.js CSV to Markdown Table Converter
- Host: GitHub
- URL: https://github.com/donatj/csvtomarkdowntable
- Owner: donatj
- License: mit
- Created: 2014-09-15T21:06:30.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-12-01T07:02:53.000Z (about 1 month ago)
- Last Synced: 2024-12-26T13:05:17.053Z (13 days ago)
- Topics: csv, javascript, markdown, markdown-table
- Language: JavaScript
- Homepage: https://donatstudios.com/CsvToMarkdownTable
- Size: 479 KB
- Stars: 293
- Watchers: 8
- Forks: 47
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# CSV To Markdown Table
[![npm version](https://badge.fury.io/js/csv-to-markdown-table.svg)](https://badge.fury.io/js/csv-to-markdown-table)
![npm](https://img.shields.io/npm/dt/csv-to-markdown-table.svg?color=blue)
[![Coverage Status](https://coveralls.io/repos/github/donatj/CsvToMarkdownTable/badge.svg?branch=master)](https://coveralls.io/github/donatj/CsvToMarkdownTable?branch=master)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/donatj/csvtomarkdowntable/master/LICENSE.md)Simple JavaScript CSV to Markdown Table Converter
You can see it in action and play with the [Live Example](https://donatstudios.com/CsvToMarkdownTable).
Requires **no external libraries**. Works in Node as well as in the browser.
## Install
```bash
npm install csv-to-markdown-table
```## Usage
### CLI
This package also includes a CLI tool. You can install it globally with:
```bash
npm install -g csv-to-markdown-table
```Then you can use it like so:
```bash
$ csv-to-markdown-table --help
Usage: csv-to-markdown-table [options]
// … help output$ csv-to-markdown-table --delimiter ',' --headers < example.csv
| cats | dogs | fish |
|------|------|------|
| 1 | 2 | 3 |
| 4 | 5 | 6 |
$ csv-to-markdown-table
Reading from stdin... (press Ctrl+D at the start of a line to finish)
CSV Delimiter: \t (tab) Headers: false
[interactive input]
```### Raw JS via Global
```js
console.log(
csvToMarkdown( "header1,header2,header3\nValue1,Value2,Value3", ",", true)
);
```### Node / npm
```js
const csvToMarkdown = require("csv-to-markdown-table");console.log(
csvToMarkdown("header1,header2,header3\nValue1,Value2,Value3", ",", true)
);
```### TypeScript
```ts
import csvToMarkdown from "csv-to-markdown-table";console.log(
csvToMarkdown("header1,header2,header3\nValue1,Value2,Value3", ",", true)
);
```#### Outputs:
```markdown
| header1 | header2 | header3 |
|---------|---------|---------|
| Value1 | Value2 | Value3 |
```Which displays in markdown as:
| header1 | header2 | header3 |
|---------|---------|---------|
| Value1 | Value2 | Value3 |