Markdown Parser

Parses Markdown to Custom JSON Format

Overview

This node parses Markdown text input and converts it into a custom JSON format representing the rich text structure. It is useful when you want to transform Markdown content into a structured JSON representation that preserves formatting such as headings, lists, bold, italic, strikethrough, links, and images. This can be beneficial for workflows that need to display or manipulate rich text content in a standardized JSON form, for example, preparing content for custom rendering engines, exporting formatted text to other systems, or further processing within n8n.

Practical examples:

  • Converting user-written Markdown notes into JSON for storage or display in a custom app.
  • Transforming Markdown-based documentation into a JSON format consumable by a web frontend.
  • Extracting structured content from Markdown emails or messages for automated workflows.

Properties

Name Meaning
Markdown Text The markdown text to convert to a custom JSON format. Supports headings, lists, links, images, and inline styles like bold, italic, and strikethrough.

Output

The node outputs an array of items, each containing a json object with two fields:

  • richTextJson: An array of JSON strings, each representing a block element (e.g., heading, paragraph, list item) with styling information. Each block has a tag (like "wrapper"), style properties (such as font size), and children elements describing text segments, links, or images with their respective styles (bold, italic, strikethrough).

  • richJson: A flattened array of objects representing the parsed content in a simpler JSON format. It includes:

    • Text elements with optional styles (bold, italic, strikethrough).
    • URL elements showing link text and href.
    • Image elements with URLs.

This output allows downstream nodes or systems to consume the rich text content either as detailed styled blocks (richTextJson) or as a simplified linear sequence (richJson).

If the Markdown contains images, they are represented with their source URLs and fixed dimensions in the JSON output.

Dependencies

  • The node uses the external library markdown-it for parsing Markdown syntax.
  • No additional API keys or external services are required.
  • Ensure that the markdown-it package is available in the n8n environment where this node runs.

Troubleshooting

  • Empty or malformed output: If the input Markdown text is empty or invalid, the output arrays may be empty or contain minimal data. Verify the Markdown input correctness.
  • Unsupported Markdown features: Some advanced Markdown syntax or plugins are not supported; only basic elements like headings, paragraphs, bullet lists, links, images, and inline styles (bold, italic, strikethrough) are handled.
  • Encoding issues in URLs: Links are URI-encoded; if URLs appear incorrect, check the original Markdown syntax.
  • Large Markdown inputs: Very large Markdown texts might impact performance; consider splitting input if necessary.

Links and References

Discussion