Markdown Content to Structured Notion Blocks - n8n Workflow

Automate complex data transformation using this n8n workflow. Convert raw Markdown files into structured Notion blocks using a custom Code n8n node for seamless publishing.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Users needing to synchronize extensive Markdown documentation with Notion automatically.

  • Technical content creators seeking to streamline their publishing pipelines using n8n templates.

  • Developers or automators who require advanced examples of JavaScript logic within an n8n node.

  • Anyone looking to use n8n to integrate content systems with Notion's API.

Overview

This powerful n8n workflow solves the common problem of moving richly formatted text from Markdown into Notion without losing structure. Integrating raw text can be challenging due to Notion's block-based architecture. This n8n template leverages a sophisticated Code n8n node containing custom JavaScript to accurately parse complex Markdown syntax—including headers (H1, H2, H3), bulleted and numbered lists, code blocks with language detection, quotes, links, and rich text formatting (bold/italic). It generates the precise JSON block structure required by the Notion API, providing a robust, production-ready solution for automated content synchronization and enhancing the functionality of your n8n automation platform.

How it Works

The n8n workflow begins with the manual n8n trigger, initiating the automation process. First, the 'Mock data' n8n node introduces a sample Markdown string into the data stream, simulating input from a previous step in a real-world n8n workflow. This Markdown content is then processed by the critical 'Convert into Notion blocks' n8n node, a custom Code n8n node. This node executes comprehensive JavaScript logic that iterates line-by-line, recognizing Markdown patterns and transforming them into valid Notion block JSON objects (paragraph, heading, code, divider, etc.). It also handles inline formatting and link conversion. The final step uses the 'Insert Notion page content' n8n node, which is an HTTP Request node configured to use the Notion API. It sends a PATCH request, inserting the generated array of Notion blocks ($json.blocks) into a specified Notion page ID, completing the data transformation and insertion within the n8n environment.

Installation Guide


  1. Import this n8n workflow JSON into your n8n instance. 2. Credentials: Ensure you have a Notion API connection credential configured in your n8n setup. This credential must provide the n8n workflow access to the target Notion page or database. 3. Data Source Replacement: The 'Mock data' n8n node is for testing only. Replace it with your actual data source (e.g., a Webhook n8n trigger, a file reading n8n node, or an AI generation output) ensuring the Markdown content is available under the key named output. 4. Action Configuration: In the 'Insert Notion page content' HTTP Request n8n node, you must update the URL. Replace the placeholder block ID in the endpoint URL (e.g., .../blocks/2255b6e0c94f80e7951df98d53ce2c39/children) with the actual ID of the Notion page you intend to populate or update using this n8n template.

Node Details

When clicking ‘Execute workflow’ (Manual Trigger n8n trigger): This is the entry point, primarily used for testing and development of this n8n template, allowing immediate execution of the logic.
Mock data (Set n8n node): Provides static Markdown content under the key output. This n8n node simulates data input for the rest of the n8n workflow and should be replaced by a live data source.
Convert into Notion blocks (Code n8n node): The core intelligence of this n8n workflow. It contains complex functions to correctly parse various Markdown elements (headers, lists, quotes, code, and inline rich text) and meticulously convert them into the required Notion block JSON structure, including handling links and annotations. This custom Code n8n node is essential for the transformation.
Insert Notion page content (HTTP Request n8n node): Configured to execute a PATCH request to the Notion API (/v1/blocks/{page_id}/children). It uses the blocks array output ({{ $json.blocks }}) from the previous n8n node as the request body to successfully upload the structured content to Notion. This node requires a predefined Notion API credential.

Related n8n Workflows

Free

Nodes: 5 Nodes
Updated: December 26 2025
View all
Created by

Featured*