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.
Common errors
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'
Warnings
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.
Install
npm install mdt2json-ts yarn add mdt2json-ts pnpm add mdt2json-ts Imports
- default wrong
const mdt2json = require('mdt2json-ts')correctimport mdt2json from 'mdt2json-ts' - parseTable wrong
import { parseTable } from 'mdt2json-ts/parseTable'correctimport { parseTable } from 'mdt2json-ts' - MarkdownTableParser wrong
import MarkdownTableParser from 'mdt2json-ts'correctimport { MarkdownTableParser } from 'mdt2json-ts'
Quickstart
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"}]