AI-Powered Markdown to Contentful Rich Text Converter - n8n Workflow

Use this comprehensive n8n workflow to automatically convert Markdown content into validated Contentful Rich Text JSON using an AI agent (GPT-4), ensuring perfect formatting for headless CMS publishing.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Content Strategists and Developers who frequently migrate or publish articles written in Markdown to Contentful.
Automation Specialists looking for robust, reusable n8n templates involving complex AI transformations.
Teams needing a reliable way to handle Contentful's strict Rich Text JSON requirements without manual intervention.
Users seeking to leverage the advanced capabilities of the n8n node ecosystem for data modeling.

Overview

Managing content deployment to headless CMS platforms like Contentful often requires converting flexible formats, such as Markdown, into proprietary JSON structures—specifically the highly complex Rich Text format. This specialized n8n workflow solves this pain point by employing an AI agent, leveraging its understanding of both Markdown and Contentful's schema. This particular n8n workflow is designed to ensure strict adherence to the required Rich Text JSON structure, including mandatory properties like data: {} and correct node linking, which are frequent sources of validation errors. By chunking the input content before processing, this n8n template handles large articles efficiently. The result is a seamless automated content pipeline, from raw Markdown input via an n8n trigger to a fully structured and published Contentful entry.

How it Works

This automation starts with the 'When Executed by Another Workflow' n8n trigger, which receives the full content payload (metadata and raw Markdown content).


  1. Splitting Content: The incoming raw Markdown is processed by the 'Split by Headings' n8n node (a Code node) which breaks the text into smaller chunks based on ### headings. This ensures the AI model can handle long documents without running into token limits or context loss, a critical optimization for this n8n workflow.

  2. AI Conversion: Each chunk is passed to the 'Markdown to Contentful format' Langchain Agent n8n node. This node uses a highly detailed system prompt—including specific examples and Contentful documentation rules—to instruct the connected OpenAI Chat Model (a specific n8n node) to convert the Markdown chunk into a fragment of valid Contentful Rich Text JSON.

  3. Combining Fragments: The 'Combine Rich Text Objects' Code n8n node collects all these individual JSON fragments generated by the AI agent and merges them into a single, cohesive Rich Text document object.

  4. Data Merge and Formatting: The 'Merge1' n8n node recombines the original entry metadata (title, slug, keywords) with the newly generated Rich Text object. The subsequent 'Format1' Code n8n node then structures this combined data into the exact API payload format required by Contentful, including defining the content type and localizing fields (e.g., "en-US": value).

  5. Publishing: Finally, the 'Create newly formatted Contentful Entry' HTTP Request n8n node posts the completed JSON payload to the Contentful Management API, creating the new entry. This entire process demonstrates the power of a customized n8n template for complex data manipulation.

Installation Guide

To deploy this powerful n8n workflow, follow these setup steps:


  1. Import: Copy the provided n8n workflow JSON and import it into your n8n instance.

  2. OpenAI Credentials: Ensure the 'OpenAI Chat Model' n8n node is configured with a valid OpenAI API Key credential.

  3. Contentful Setup (HTTP Request): Locate the 'Create newly formatted Contentful Entry' HTTP Request n8n node. You must update three key configurations:

URL: Replace {INSERTYOURSPACE} in the URL with your actual Contentful Space ID.
Headers: Replace {INSERT TOKEN HERE} in the Authorization header with your Contentful Management API access token.
* Headers: Verify the X-Contentful-Content-Type header matches the Contentful content type ID you intend to use (currently set to knowledgeBaseArticle).

  1. Testing: Since this uses an 'Execute Workflow' n8n trigger, run it manually and provide the example JSON payload containing your sample article data and Markdown content for testing the n8n template.

Node Details

When Executed by Another Workflow (n8n trigger): Serves as the starting point, enabling external systems (other n8n templates, webhooks, or manual execution) to initiate the automation by providing the full article metadata and Markdown content.
Split by Headings (Code n8n node): Splits the incoming Markdown content into manageable chunks (using ### as a separator) to optimize the prompt length and improve AI reliability.
OpenAI Chat Model (LangChain LM Chat OpenAI n8n node): Provides the large language model backend (configured to use GPT-4) used by the Agent node for specialized data transformation.
Markdown to Contentful format (LangChain Agent n8n node): The core AI transformation n8n node. It dictates the behavior of the LLM using an extensive system prompt to convert Markdown structure (paragraphs, lists, headings) into compliant Contentful Rich Text JSON fragments.
Combine Rich Text Objects (Code n8n node): Aggregates the resulting Rich Text JSON fragments from all processed chunks into a single, valid Contentful document structure.
Format1 (Code n8n node): Maps the unified Rich Text content and original metadata into the final, correct structure expected by the Contentful API (including mandatory { "en-US": value } localization wrappers).


  • Create newly formatted Contentful Entry (HTTP Request n8n node): The final action n8n node responsible for sending the fully prepared JSON payload to the Contentful Management API to publish the new content entry.

Related n8n Workflows

Paid

Nodes: 7 Nodes
Updated: December 26 2025
View all
Created by
Varritech
Varritech

Build your next app 500% faster with the latest AI-powered development

Featured*