Skip to main content
Glama

convert_to_json

Idempotent

Convert Markdown to structured JSON for programmatic analysis. Transforms documents into hierarchical objects with sections, headings, paragraphs, and code blocks to enable automated processing and system integration.

Instructions

Convert Markdown to a structured JSON representation. Parses the document into a JSON object with the document title as the root key, containing arrays of section objects with headings, paragraphs, lists, code blocks, and tables. Useful for programmatic analysis or feeding structured content into other systems. Side effects: when output_path is provided, writes the JSON to disk (creates parent directories, overwrites existing files). When output_path is omitted, returns the JSON string directly. Returns: JSON string (if no output_path), or JSON { success, file_path, file_size_bytes, format } (if output_path set). Use this when you need a machine-readable AST-like representation of the Markdown content. Prefer convert_to_xml for XML-based interchange, or convert_to_csv/convert_to_xlsx for tabular data extraction.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
markdownYesThe raw Markdown source text to convert. Supports GitHub-Flavored Markdown (tables, task lists, strikethrough) and KaTeX math expressions. Pass the full document content as a string, not a file path.
titleNoOptional. A document title string. Used as the root element name or document metadata title in the output. Defaults to 'document' if omitted.
output_pathNoOptional. Absolute or relative file path (e.g. './output.txt') where the result will be saved. Parent directories are created automatically. If omitted, the converted text content is returned directly in the response as a string. If provided, the file is written to disk and a JSON summary with { success, file_path, file_size_bytes, format } is returned instead.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/XJTLUmedia/MCP_Markdown_Formatter'

If you have feedback or need assistance with the MCP directory API, please join our Discord server