Categories We Write About

Convert Notion exports to plain Markdown

When Notion exports content as Markdown, it often includes additional metadata, file structures, and formatting styles that aren’t strictly “plain Markdown.” To convert Notion exports to plain Markdown, follow these steps:


1. Export from Notion

  • Go to the Notion page or workspace.

  • Click on “⋯” > Export.

  • Choose:

    • Export format: Markdown & CSV

    • Include subpages: Yes (optional)

  • Click Export and unzip the downloaded file.


2. Clean Up the File Structure

  • Notion creates a folder for each page and subpage, with extra .md files and media/ directories.

  • Flatten the structure if you only want the Markdown content:

    • Move all .md files into a single directory.

    • Optional: Discard image/media folders if not needed.


3. Remove Notion-Specific Formatting

Typical issues in Notion-exported Markdown:

  • Internal Notion links like [](notion://...)

  • Extra ---, ##, or section dividers

  • Image embeds using syntax like ![](./media/image.png) referencing local paths

Tools to automate cleanup:

You can use CLI tools or scripts:

Using sed (Unix/macOS/Linux):

bash
# Remove Notion internal links sed -i '' 's|(notion://[^)]*)||g' *.md # Optional: Remove metadata at the top (example: title blocks) sed -i '' '/^title: /d' *.md # Remove image/media links sed -i '' '/![.*](./media/.*)/d' *.md

4. Optional: Use a Markdown Linter or Formatter

Tools like markdownlint can help reformat and tidy the content:

bash
npm install -g markdownlint-cli markdownlint '**/*.md' --fix

Or use an online Markdown beautifier to remove irregular line breaks or spacing.


5. Convert to Truly Plain Markdown (No Extras)

  • Ensure:

    • No frontmatter (---)

    • No reference-style links or non-standard syntax

    • Clean headers (#, ##), lists (-, *, 1.), and code blocks (“`)

Example cleanup result:

Before:

md
## My Notes This is a [Notion link](notion://some-id) with ![an image](./media/image1.png) ---

After:

md
## My Notes This is a link with no image.

Optional: Use a Script to Batch Clean

Here’s a simple Node.js script to clean all .md files in a folder:

js
const fs = require('fs'); const path = require('path'); const dir = './'; // your markdown files directory fs.readdirSync(dir).forEach(file => { if (file.endsWith('.md')) { let content = fs.readFileSync(path.join(dir, file), 'utf-8'); content = content .replace(/[([^]]*)](notion://[^)]*)/g, '$1') // remove Notion links .replace(/![.*](./media/.*)/g, '') // remove media links .replace(/^title: .*$/gm, '') // remove title metadata .replace(/^---$/gm, '') // remove YAML dividers .replace(/n{2,}/g, 'nn'); // clean excess blank lines fs.writeFileSync(path.join(dir, file), content.trim()); } });

Summary

To convert Notion exports to plain Markdown:

  • Export as Markdown

  • Remove Notion-specific elements (links, metadata, media)

  • Flatten structure

  • Clean using scripts or CLI tools

  • Optional: Lint/format the output

This gives you clean, portable Markdown suitable for blogs, static site generators, or documentation systems.

Share This Page:

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories We Write About