npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

json-to-md-table

v1.0.1

Published

Fast, zero-dependency utility and CLI to convert JSON arrays and JavaScript objects into clean, beautifully aligned Markdown tables.

Readme

📊 json-to-md-table

Fast, zero-dependency utility and CLI to convert JSON arrays and JavaScript objects into clean, beautifully aligned Markdown tables.

npm version License: MIT Sponsor TypeScript


✨ Features

  • ⚡ Zero Dependencies — Ultra-lightweight (~2 KB), pure native TypeScript.
  • 📐 Visually Padded & Aligned — Automatically calculates column widths so raw Markdown tables look tidy in code editors and READMEs.
  • 🎚️ Column Alignments — Full support for left (:---), center (:---:), and right (---:) alignments.
  • 🏷️ Column Filtering & Header Aliases — Select specific fields and rename column titles.
  • 🛡️ Auto-Escaping — Automatically escapes pipe characters (| -> \|) and handles multiline text to keep tables valid.
  • 🧪 Custom Cell Value Formatters — Transform currencies, dates, booleans (true -> ✅), or numbers.
  • 💻 CLI & CI/CD Ready — Pipe JSON directly or run npx json-to-md-table in GitHub Actions.
  • 📦 Dual ESM & CommonJS — Works in Node.js, Next.js, Vite, Express, and browsers.

📥 Installation

As a Library

npm install json-to-md-table

As a CLI Tool

npx json-to-md-table data.json
# or install globally
npm install -g json-to-md-table

🚀 Quick Start (Library)

1. Basic JSON to Markdown Table

import { jsonToMarkdownTable } from 'json-to-md-table';

const users = [
  { id: 1, name: 'Alice', role: 'Admin', active: true },
  { id: 2, name: 'Bob', role: 'Member', active: false },
];

console.log(jsonToMarkdownTable(users));

Output:

| id  | name  | role   | active |
| :-- | :---- | :----- | :----- |
| 1   | Alice | Admin  | true   |
| 2   | Bob   | Member | false  |

2. Custom Headers, Alignment & Formatting

import { jsonToMarkdownTable } from 'json-to-md-table';

const benchmarks = [
  { test: 'Query A', latency: 12.4, status: 'pass' },
  { test: 'Query B', latency: 154.2, status: 'slow' },
];

const table = jsonToMarkdownTable(benchmarks, {
  columns: [
    { key: 'test', header: 'Test Suite', align: 'left' },
    {
      key: 'latency',
      header: 'Latency',
      align: 'right',
      format: (val) => `${val} ms`,
    },
    {
      key: 'status',
      header: 'Status',
      align: 'center',
      format: (val) => (val === 'pass' ? '✅ Pass' : '⚠️ Warning'),
    },
  ],
});

console.log(table);

Output:

| Test Suite |   Latency |   Status   |
| :--------- | --------: | :--------: |
| Query A    |   12.4 ms |  ✅ Pass   |
| Query B    |  154.2 ms | ⚠️ Warning |

3. Convert 2D Arrays

import { twoDArrayToMarkdownTable } from 'json-to-md-table';

const headers = ['Country', 'Capital'];
const rows = [
  ['France', 'Paris'],
  ['Japan', 'Tokyo'],
];

console.log(twoDArrayToMarkdownTable(headers, rows));

💻 CLI Usage

# Convert a JSON file and print to terminal:
npx json-to-md-table results.json

# Save output to a markdown file:
npx json-to-md-table results.json -o TABLE.md

# Pipe from another command (e.g. curl or jq):
curl -s https://api.example.com/items | npx json-to-md-table

⚙️ Options Reference

jsonToMarkdownTable(data, options)

| Option | Type | Default | Description | |---|---|---|---| | columns | Array<string \| ColumnDefinition> | all keys | Columns to include, their order, and formatting. | | alignment | 'left' \| 'center' \| 'right' \| Array | 'left' | Global or per-column alignment shorthand. | | padCells | boolean | true | Pads cells with spaces for visually aligned raw markdown. | | escapePipes | boolean | true | Escapes \| characters within cell contents. | | emptyPlaceholder | string | '-' | Text displayed for null or undefined values. |


🛠 Development & Testing

# Install dependencies
npm install

# Run unit tests
npm test

# Build dual ESM/CJS bundles + CLI executable + .d.ts types
npm run build

💖 Support the Project

If you find this package useful, consider sponsoring its ongoing development and maintenance: 👉 Sponsor @Piratha97 on GitHub Sponsors

📄 License

MIT © 2026 Pirapaakaran Pirathapan