mdt2json

raw JSON →
1.1.0 verified Fri May 01 auth: no javascript

A lightweight Markdown table to minified JSON transpiler with CLI and programmatic API. v1.1.0 released 2025-07-29. Supports converting markdown tables to compact JSON, including optional HTML inclusion. Ships TypeScript types. Differentiators: no dependencies, ESM/CJS dual module, simple API with parse function and CLI tool. Compared to alternatives like markdown-table-to-json, this offers minified output and HTML embedding.

error Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/mdt2json/dist/index.js from /path/to/project/index.js not supported.
cause Package is ESM-only; CommonJS require() fails.
fix
Use import or dynamic import; set type: module in package.json.
breaking Package renamed from 'mdtable2json' to 'mdt2json' between v0.2.0 and v1.0.0. Existing imports from 'mdtable2json' will break.
fix Update all imports to 'mdt2json' and reinstall.
deprecated CLI flag --include-html added in v1.1.0 is experimental and may change in future releases.
fix Use with caution; no fix needed yet.
gotcha Module is ESM-only (type: module in package.json). Using require() or running in CommonJS environment will throw an error.
fix Set "type": "module" or use dynamic import: const { parse } = await import('mdt2json').
npm install mdt2json
yarn add mdt2json
pnpm add mdt2json

Parse a markdown table string to minified JSON array, demonstrating basic usage with ESM import.

import { parse } from 'mdt2json';
const markdown = `| Name | Age |
| --- | --- |
| Alice | 30 |
| Bob | 25 |`;
const json = parse(markdown);
console.log(json);
// [["Name","Age"],["Alice",30],["Bob",25]]