# nx-json-parser

> Transform strings to JSON based on Markdown structure using unified/remark

Latest version **1.3.0** (published 2026-01-03) · ISC license · 0 weekly downloads

## Install

```sh
npm install nx-json-parser
pnpm add nx-json-parser
yarn add nx-json-parser
bun add nx-json-parser
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2026-01-03 |
| First published | 2026-01-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 6 |
| Unpacked size | 125.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | nx-morpheus |
| Keywords | markdown, json, parser, unified, remark |

## Links

- npm: https://www.npmjs.com/package/nx-json-parser
- npm.io page: https://npm.io/package/nx-json-parser

## Dependencies (6)

- [unified](https://npm.io/package/unified.md) ^11.0.5
- [nx-helpers](https://npm.io/package/nx-helpers.md) ^1.5.0
- [remark-gfm](https://npm.io/package/remark-gfm.md) ^4.0.1
- [remark-parse](https://npm.io/package/remark-parse.md) ^11.0.0
- [unist-util-visit](https://npm.io/package/unist-util-visit.md) ^5.0.0
- [mdast-util-to-string](https://npm.io/package/mdast-util-to-string.md) ^4.0.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.3.0 (latest) — 2026-01-03
- 1.2.1 — 2026-01-02
- 1.2.0 — 2026-01-02
- 1.1.0 — 2026-01-02
- 1.0.0 — 2026-01-02

## README

# nx-json-parser

A robust Markdown-to-JSON transformer SDK built on top of `unified`, `remark`, and `remark-gfm`. 

Designed for structured data extraction from LLM outputs and other Markdown-formatted strings.

## Features

- **AST-Based Parsing**: Uses `remark` for reliable, production-grade Markdown parsing (no regex hell).
- **Table Support**: Automatically converts Markdown tables into arrays of JavaScript objects using `remark-gfm`.
- **List Support**: Smartly handles lists, converting them to arrays.
- **Bullet-Style Sections**: Includes a custom plugin to detect and transform bulleted "sections" (e.g., `- Title: Content`) into structured JSON keys.
- **CamelCase Normalization**: Automatically transforms headings and table headers into `camelCase` keys.
- **Extensible**: Built on the `unified` ecosystem, allowing for additional plugins (math, frontmatter, etc.).

## Installation

```bash
npm install nx-json-parser
```

## Usage

### Basic Usage

```typescript
import { markdownToJson } from 'nx-json-parser';

const md = `
# Summary
The product is a high-performance database.

## Key Features
- Scalable
- Secure
- Fast
`;

const result = markdownToJson(md);
/*
{
  summary: "The product is a high-performance database.",
  keyFeatures: ["Scalable", "Secure", "Fast"]
}
*/
```

### Table Support

```typescript
const md = `
### Database Performance
| Metric | Value | Status |
|--------|-------|--------|
| Latency| 5ms   | OK     |
| Throughput | 10k ops/s | High |
`;

const result = markdownToJson(md);
/*
{
  databasePerformance: [
    { metric: "Latency", value: "5ms", status: "OK" },
    { metric: "Throughput", value: "10k ops/s", status: "High" }
  ]
}
*/
```

### Bullet-Style Sections

LLMs often output sections using bullet points. `nx-json-parser` detects this pattern and treats them as structured keys:

```typescript
const md = `
- Short Answer
The sky appears blue due to Rayleigh scattering.

- Technical Detail
Short-wavelength light is scattered more strongly by atmospheric gases.
`;

const result = markdownToJson(md);
/*
{
  shortAnswer: "The sky appears blue due to Rayleigh scattering.",
  technicalDetail: "Short-wavelength light is scattered more strongly by atmospheric gases."
}
*/
```

## API

### `markdownToJson(markdown: string): any`
Converts a Markdown string to a JSON object.

### `JSONTransformer`
The main class for transformation. You can provide a custom `RemarkParser` if needed.

```typescript
import { JSONTransformer, RemarkParser } from 'nx-json-parser';

const transformer = new JSONTransformer({
  parser: new RemarkParser()
});
const result = transformer.transform(md);
```

## License

ISC

---
_Source: https://npm.io/package/nx-json-parser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
