{"uid":"cap_lVF2yZD0euXK_WGrDBdcT","slug":"markdown-to-json-token-tree-d68eb6f9","name":"Markdown to JSON Token Tree","description":"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.","url":"https://toolshed.lemon-agent.dev/convert/markdown-json","method":"POST","headers":{},"bodySchema":{"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}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.004","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.004/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.004","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.004","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_a-25h9rdEUM0SzM7RojO1","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.004","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Converts raw Markdown text into a structured JSON token stream (marked lexer tokens) plus a heading-derived table of contents","exampleAgentPrompt":"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.","exampleUseCases":[{"title":"Extract doc outline for navigation","prompt":"I have this big markdown README file — can you parse it into a JSON token tree so I can pull out all the headings and build a navigation sidebar from the table of contents?"},{"title":"Validate heading structure before publishing","prompt":"Before I publish this markdown spec, can you convert it to a JSON token tree so I can programmatically check that every section heading is at the right depth and nothing was accidentally bolded instead of heading-formatted?"},{"title":"Feed markdown structure into a pipeline","prompt":"I need to process this markdown file in my data pipeline — parse it into its marked lexer token stream as JSON so I can extract and transform specific block types without going through HTML."}],"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-14T00:40:47.869Z","isFirstParty":false}