How to use the markdown to json converter
- Paste or type your Markdown source into the text area.
- The converter parses the text instantly into an array of JSON nodes.
- Copy the resulting JSON to use in your application or API pipeline.
Supported Markdown Subset
This markdown to json tool handles a practical subset of CommonMark rather than the full specification. The supported block elements are ATX headings (levels 1 through 6), paragraphs, unordered lists using hyphens, asterisks or plus signs, ordered lists starting with digits, fenced code blocks delimited by three backticks with an optional language tag, blockquotes prefixed with a greater-than sign, horizontal rules made of three or more hyphens, asterisks or underscores, and simple pipe-delimited tables.
Inline formatting includes strong emphasis wrapped in double asterisks or double underscores, italic emphasis with single asterisks or underscores, inline code in backticks, links in bracket-parenthesis syntax, and images prefixed with an exclamation mark. Nested lists, reference-style links, indented code and setext headings are supported; footnotes and HTML blocks are not.
How the Parser Works
The conversion happens in two passes. First, the input is split into lines and grouped into blocks. A line starting with one to six hash characters becomes a heading node. Three or more matching punctuation characters on their own line become a horizontal rule. Lines beginning with a list marker are collected into a list node, and lines after a greater-than sign form a blockquote. Fenced code blocks capture everything between opening and closing backtick fences. Remaining non-empty lines are joined into paragraph nodes.
Second, each block's text content is scanned for inline patterns. The parser looks for image syntax first, then links, then strong markers, italic markers and backticks. Each match produces a child node with its own type and properties. Text values keep their characters exactly as typed (no HTML entities), raw HTML is treated as text, and link and image addresses with schemes other than http, https, mailto, tel, ftp or relative are replaced by an empty string.
JSON Output Structure
The output is always a JSON array. Each element is an object representing a block or inline node. Block nodes carry a type string such as heading, paragraph, list or code_block. Headings include a numeric level property from 1 to 6. Code blocks include a lang string when a language identifier follows the opening fence. Lists contain an ordered boolean and an items array where each item holds its own parsed inline children.
Tables produce a node with headers and rows arrays, each containing arrays of inline nodes. Links and images store their destination URL in an href or src property alongside the parsed child nodes for the label or alt text. This consistent structure makes it straightforward to traverse the tree programmatically.
Practical Use Cases
Converting markdown to json is useful whenever you need to process document structure programmatically. Static site generators often parse Markdown into an abstract syntax tree before rendering templates. By obtaining a clean JSON representation, you can feed the data into custom renderers, search indexes or content management APIs without relying on heavy parsing libraries at runtime.
Another common scenario is migrating documentation. If you have existing Markdown files and need to import them into a system that expects structured data, this converter bridges the gap. You can also pair it with tools like markdown to html if your final target is web markup, or use csv to json when working with tabular data sources instead.
Common Mistakes to Avoid
Because this parser targets a specific subset, certain valid CommonMark constructs will not produce the expected nodes. Reference-style links are resolved, including definitions that come later in the document. Indented code blocks (four spaces) become code_block nodes like fenced ones.
Mixing tabs and spaces for list indentation can cause items to be grouped incorrectly. Stick to consistent spacing. Raw HTML in your Markdown source is kept as text, not parsed. If you need to preserve actual HTML structures, consider converting your source with an html to json tool instead, which is designed for that format.
Worked examples
| Example | Input | Result |
|---|---|---|
| Headings and paragraph | Markdown input: # Title / A paragraph with **bold**. | [{"type":"heading","level":1,"children":[{"type":"text","value":"Title"}]},{"type":"paragraph","children":[{"type":"text","value":"A paragraph with "},{"type":"strong","children":[{"type":"text","value":"bold"}]},{"type":"text","value":"."}]}] |
| List and link | Markdown input: - [Home](/) / - About | [{"type":"list","ordered":false,"items":[{"children":[{"type":"link","href":"/","children":[{"type":"text","value":"Home"}]}]},{"children":[{"type":"text","value":"About"}]}]}] |
| Fenced code block | Markdown input: ```js / console.log('hi'); / ``` | [{"type":"code_block","lang":"js","value":"console.log('hi');"}] |
| Simple table | Markdown input: | Name | Age | / | --- | --- | / | Alice | 30 | | [{"type":"table","align":[null,null],"headers":[[{"type":"text","value":"Name"}],[{"type":"text","value":"Age"}]],"rows":[[[{"type":"text","value":"Alice"}],[{"type":"text","value":"30"}]]]}] |
FAQ
Does this markdown to json converter upload my text?
No. All parsing runs locally in your browser using JavaScript. Your Markdown source never leaves your device.
What Markdown features are supported?
Headings, paragraphs, bold, italic, inline code, fenced code blocks, links, images, unordered and ordered lists, blockquotes, horizontal rules and simple pipe tables.
Are raw HTML tags preserved in the JSON?
No. No. Raw HTML is not parsed or preserved as structure: it appears as ordinary text in text nodes, with no entity escaping.
Can I convert the JSON back to Markdown?
This tool only converts in one direction. To go from structured data back to Markdown, you would need a separate renderer or template engine.
How are tables represented in the JSON output?
Tables become a node with type table, containing a headers array and a rows array. Each cell holds an array of parsed inline nodes.
Is this a full CommonMark parser?
No. It implements a practical subset of CommonMark. Nested lists and reference links are supported; footnotes and HTML blocks are omitted. List items carry their first paragraph in children and any nested content in blocks.