mdt2json-ts

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

mdt2json-ts is a TypeScript-based transpiler that converts Markdown tables into minified JSON arrays. Version 0.1.0 is the initial release, with no active release cadence. It differentiates from similar tools by producing compact JSON output without intermediate steps, targeting developers who need to extract structured data from Markdown tables programmatically. The package ships with TypeScript type definitions for type-safe usage.

error SyntaxError: Unexpected token 'export'
cause Trying to require an ESM-only module with CommonJS.
fix
Use ESM imports or set type: module in package.json.
error TypeError: mdt2json is not a function
cause Using named import incorrectly as default.
fix
Use import mdt2json from 'mdt2json-ts'
gotcha Table rows must be separated by newlines; inline tables not supported.
fix Ensure each row is on its own line.
gotcha Only pipe-separated tables are supported; GFM tables with dashes only.
fix Use pipe characters and include the separator line.
gotcha JSON output is minified; no pretty-print option available.
fix Use JSON.stringify(result, null, 2) for formatting.
npm install mdt2json-ts
yarn add mdt2json-ts
pnpm add mdt2json-ts

Demonstrates converting a Markdown table string to a minified JSON array using the default export.

import mdt2json from 'mdt2json-ts';

const markdown = `| Name | Age |
|------|-----|
| Alice | 30 |
| Bob | 25 |`;

const json = mdt2json(markdown);
console.log(json);
// Output: [{"Name":"Alice","Age":"30"},{"Name":"Bob","Age":"25"}]