Skip to content

Every 15 minutes

Export finished Notion pages to Markdown

When a page is marked ready, you get it as Markdown by email and the page is marked as exported.

Runs
Every 15 minutes
Apps
Notion
AI
Not needed
Access
read+write

Send this to your assistant

Create a ClickRuntime automation: every 15 minutes, check my Notion Blog database for pages with Status set to Ready. Convert each one to Markdown, email it to me, and set its Status to Exported.

Paste it into your assistant. It tells you what it will send or change before it runs live.

First time? Adding ClickRuntime to your assistant takes about two minutes.

Why use it

Why teams use this automation

A documentation lead writes help articles in Notion, but the website, the support tool and the developer wiki all need Markdown or HTML. So every finished article gets copied out by hand, formatting breaks on tables and toggles, and someone forgets to re-export after the last revision. The published version drifts away from what the team actually approved.

Every 15 minutes, the Notion database is checked for pages marked ready. For each one, all nested blocks are fetched (headings, lists, callouts, code, toggles inside toggles), converted into clean Markdown or HTML and emailed to you with the page title as the subject. The page's status is then set to Exported so it is not sent twice.

It also fits teams who archive meeting notes, publish a changelog, or hand finished copy to an agency.

What you get out of it

  • Published text matches approved text

    The file you receive is generated from the Notion page at the moment it was marked ready, so the version on your site cannot quietly lag behind the final draft the team signed off on.

  • No more broken formatting from copy and paste

    Nested lists, tables, callouts and code blocks are converted from the block structure itself. That avoids the stray characters and flattened indentation that appear when pages are pasted into another writing tool.

  • Writers stay in one tool

    Authors keep drafting where they are comfortable and only flip a status. Developers get the file in a format their static site generator or help center already accepts. That keeps the writing workflow unchanged for the whole team.

  • Nothing is exported twice

    Setting the status to Exported after each send prevents duplicate emails for the same page, so the inbox does not fill with identical attachments and nobody wonders which one is current.

  • A trail of every release

    Each email is a timestamped snapshot of a page, handy when someone asks what the pricing page said before the rewrite or when a legal review needs the earlier text.

How it works

What happens, step by step

  1. Every 15 minutes ClickRuntime checks your Notion database for pages marked as ready.

  2. It reads each page, including headings, lists and nested blocks.

  3. The page is turned into clean Markdown and emailed to you.

  4. The page's status is set to Exported so it isn't sent again.

Before it runs live

  • Connect Notion and share the database you want it to use

What you get

RunsEvery 15 minutes
Export finished Notion pages to Markdowntoday, 9:00Succeeded
Email · Exported: Five lessons from our Acme migration# Five lessons from our Acme migration ## 1. Freeze the schema early

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • Your own rules

    Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.

  • Any number of apps

    One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.

  • AI where it helps

    Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.

  • On a schedule or on each event

    Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.

Changes you can ask for

  • Act only on the items that match your own rules, and skip the rest
  • Add an AI step, for example to summarize, sort or draft a reply
  • Add another app, for example also send it to Slack
  • Combine it with other Notion steps into one automation

Under the hood

The code that runs this automation

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
export_notion_pages_to_markdown_or_html.pyexample
from clickruntime import on_trigger, report_fetched, credentials, http, notify

NOTION = "https://api.notion.com/v1"

def headers():
    return {"Authorization": f"Bearer {credentials.secret('NOTION_TOKEN')}", "Notion-Version": "2022-06-28"}

def query(db, body=None):
    resp = http.post(f"{NOTION}/databases/{db}/query", headers=headers(), json=body or {})
    resp.raise_for_status()
    return resp.json()["results"]

def title(page, prop="Name"):
    return "".join(t["plain_text"] for t in page["properties"][prop]["title"])

BLOG = "blog-database-id"
PREFIX = {"heading_1": "# ", "heading_2": "## ", "heading_3": "### ", "bulleted_list_item": "- ",
          "numbered_list_item": "1. ", "quote": "> ", "paragraph": ""}

def to_markdown(page_id):
    blocks = http.get(f"{NOTION}/blocks/{page_id}/children", headers=headers(), params={"page_size": 100}).json()["results"]
    lines = []
    for b in blocks:
        rich = b.get(b["type"], {}).get("rich_text", [])
        if b["type"] in PREFIX:
            lines.append(PREFIX[b["type"]] + "".join(t["plain_text"] for t in rich))
    return "\n\n".join(lines)

@on_trigger
def run(event):
    pages = query(BLOG, {"filter": {"property": "Status", "select": {"equals": "Ready"}}})
    report_fetched(len(pages))
    if not pages:
        return {"summary": "Nothing ready"}
    for p in pages:
        notify.email_me(f"Exported: {title(p)}", f"# {title(p)}\n\n{to_markdown(p['id'])}")
        http.patch(f"{NOTION}/pages/{p['id']}", headers=headers(),
                   json={"properties": {"Status": {"select": {"name": "Exported"}}}}).raise_for_status()
    return {"exported": len(pages)}

FAQ

Common questions

How does it know a page is ready to export?
It looks for pages whose status property has the value you pick, such as Ready or Approved. Pages in any other state are skipped. Once a page is exported, its status flips so it drops out of the next check.
Are images and embedded files included in the export?
Images and files are written as links to where Notion hosts them. Notion's file links can expire after a while, so if you need permanent copies you should download the images when the email arrives.
Can it send HTML for some pages and Markdown for others?
Yes. You can pick the format by a database property, for example a Format select with Markdown or HTML, so each page gets the output its destination expects. If a page has no value, a default format is used.
What permissions does it need?
read+write. Nothing else in your accounts is used.
Does it need AI?
No. It runs without AI, so it doesn't use your plan's AI allowance.
How many runs does it use?
One run each time it checks. Checks that find nothing new and stop right away aren't counted.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

Set up “Export finished Notion pages to Markdown” from your assistant

Copy the prompt above, or connect your assistant first. Free plan, no credit card.