# Markdown to JSON Token Tree

> Markdown to JSON Token Tree is a paid API for AI agents from toolshed.lemon-agent.dev, paid per call via x402, $0.004/call, status unknown (last checked 2026-09-14).

Converts raw Markdown text into a structured JSON token stream (marked lexer tokens) plus a heading-derived table of contents

## Facts

- Endpoint: POST https://toolshed.lemon-agent.dev/convert/markdown-json
- Price: $0.004/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/markdown-to-json-token-tree-d68eb6f9
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_lVF2yZD0euXK_WGrDBdcT

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability markdown-to-json-token-tree-d68eb6f9 -d '<json body>'
```

Example prompt: Parse this markdown document into a JSON token tree and give me the table of contents — I want the structured heading list and the full marked lexer token stream, not rendered HTML.

## When to prefer this

Choose this endpoint when you need the structural parse tree of a Markdown document — specifically the lexer token stream and heading-accurate table of contents — rather than rendered HTML output. It is ideal when you want to programmatically inspect or transform markdown structure (e.g. extract all headings, validate document outline, feed tokens into a pipeline) without round-tripping through HTML. Prefer it over the sibling Markdown-to-HTML endpoint when you need machine-readable structure, and over the frontmatter endpoint when you need the full document body tokenized, not just the YAML front matter.

## Known failure modes

- Input exceeds 256 KB limit — request rejected
- Malformed or non-UTF-8 body — parse error returned
- Empty body — returns empty toc and tokens arrays
- Non-markdown plain text — tokenized but toc may be empty if no headings present
- Payment failure — 402 response before processing begins

## How this service works

Markdown to a JSON token tree. POST Markdown; the response is {"toc": [{depth, text}], "tokens": [...]} — the marked lexer's token stream plus a table of contents derived from the real headings. The document's structure without rendering it to HTML and parsing that back. A bold line pretending to be a heading was never structure and is not in the toc.

## Output

A JSON object with two keys: 'toc' (an array of objects with 'depth' and 'text' fields, one per genuine heading in the document) and 'tokens' (the full marked lexer token stream array representing every block-level element in the markdown). Only real headings (# syntax) appear in the toc — bold text styled to look like headings is excluded.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method",
    "bodyType",
    "body"
   ],
   "properties": {
    "body": {
     "type": "string",
     "maxLength": 262144,
     "description": "the raw Markdown file as the request body, up to 256 KB"
    },
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "type": "string",
     "const": "POST"
    },
    "bodyType": {
     "type": "string",
     "const": "text"
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type",
    "format"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "text"
    },
    "format": {
     "type": "string",
     "const": "application/json",
     "description": "the converted JSON file as the response body (application/json)"
    },
    "example": {
     "type": "string",
     "description": "the sample request body above, converted — what a the converted JSON file as the response body (application/json) looks like"
    }
   },
   "additionalProperties": false
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/markdown-to-json-token-tree-d68eb6f9/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from toolshed.lemon-agent.dev](https://www.zero.xyz/host/toolshed.lemon-agent.dev/llms.txt)
