Notion to Markdown: fix file names, links and databases
Notion to Markdown, step by step. Export as Markdown & CSV, then strip the IDs from file names, repair links and turn database CSVs into tables.

To get from Notion to Markdown, open the page, choose ••• > Export, pick Markdown & CSV, turn on Include subpages, and download the zip. Each page becomes a .md file, each full-page database becomes a .csv file, and attachments sit in folders beside the pages. The raw export needs three fixes before it is pleasant to use: file names end in a 32-character ID, internal links point at those long names, and databases are spreadsheets rather than Markdown tables.
This guide covers the export itself and a short script that fixes the names and links in one pass. If you are still deciding whether to move your notes out of Notion at all, leaving Notion for plain text covers that decision. The Notion steps below follow Notion's help page Export your content (checked November 2026).
How do you export a Notion page as Markdown?
Export from the page you want, on the desktop app or the web:
- Open the page. To export a whole section of your sidebar, open its top page.
- Click ••• in the top right corner and choose Export.
- Set the format to Markdown & CSV.
- Turn on Include subpages so nested pages come along as separate files.
- Leave Create folders for subpages on if you want the page tree kept as folders.
- Click Export and save the zip.
The mobile app has the same Export item in the ••• menu, sends the file through the share sheet, and also emails a download link. Guests need full access to a page to see the export option, and on Enterprise plans an owner can switch exporting off for the workspace.
How do you export a whole workspace?
Go to Settings in the sidebar, then General under Workspace, and choose Export all workspace content. Notion prepares the file in the background and emails a download link that expires after seven days; its help page says processing can take up to 30 hours. An export by a workspace owner includes every teamspace, and it is available on desktop and the web, not in the mobile app.
For a personal migration, exporting the few top-level pages you actually use is often faster than exporting everything and deleting what you don't need.
What is inside the Notion export zip?
Unzipped, a small export looks like this:
Projects 1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d.md
Projects 1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d/
Launch plan 9f8e7d6c5b4a39281706f5e4d3c2b1a0.md
Launch plan 9f8e7d6c5b4a39281706f5e4d3c2b1a0/
screenshot.png
Tasks 0a1b2c3d4e5f60718293a4b5c6d7e8f9.csv
Tasks 0a1b2c3d4e5f60718293a4b5c6d7e8f9/
Write the brief 5e4d3c2b1a0f9e8d7c6b5a4938271605.md
| In Notion | In the export |
|---|---|
| A page | A .md file named after the page, plus an ID |
| Subpages | A folder with the same name and ID as the parent page |
| A full-page database | A .csv file of the current or default view, plus a folder with one .md file per row that has content |
| Images and attachments | Files in the page's folder, linked by relative path |
| Callout blocks | HTML, because Markdown has no callout syntax |
| Links between pages | Relative links to the other .md files, URL-encoded |
Two details from Notion's documentation matter here. Only one view of each database is exported, so filters and sorts from other views are gone. Callouts are written as HTML inside the Markdown file, which is valid but noisy; the HTML in Markdown page explains how editors treat it.
Check toggles, synced blocks and embeds in your own export as well. They have no direct Markdown form, so look at a page that uses them before you convert hundreds.
How do you remove the IDs from file names?
Rename the files and rewrite the links at the same time. If you rename by hand, every link that pointed at the old name breaks.
The script below works on an unzipped export folder. It removes the space and 32-character ID from every file and folder name, and removes the same ID (written as %20 plus the ID) from link targets inside every Markdown file. Run it on a copy of the export, not your only copy.
import pathlib
import re
import sys
ID = re.compile(r"(?:%20| )[0-9a-f]{32}(?=\.|_|/|%2F|\)|$)")
root = pathlib.Path(sys.argv[1])
# 1. Remove IDs from link targets inside every Markdown file
for md in root.rglob("*.md"):
text = md.read_text(encoding="utf-8")
md.write_text(ID.sub("", text), encoding="utf-8")
# 2. Rename files and folders, deepest first
paths = sorted(root.rglob("*"), key=lambda p: len(p.parts), reverse=True)
for path in paths:
new = path.with_name(ID.sub("", path.name))
if new == path:
continue
if new.exists():
print("name already taken, left as is:", path)
continue
path.rename(new)
Save it as clean_notion.py and run python3 clean_notion.py "Notion export" (use python on Windows). Two pages with the same title in the same folder can't both lose their ID, so the script leaves the second one alone and prints its path. Rename it and fix the links to it by hand.
If Windows refuses to unzip the export because paths are longer than 260 characters, Notion suggests exporting again with Create folders for subpages turned off, or extracting with 7-Zip.
How do you turn a database CSV into a Markdown table?
Small databases read well as a Markdown table inside a note. Pandoc converts a CSV file in one command:
pandoc -f csv -t gfm "Tasks.csv" -o "Tasks table.md"
Property types do not carry over as types. Dates, selects, people and relations all arrive as text, and a relation shows the related page's name rather than a working link. For more ways to convert, including spreadsheets and scripts, see CSV to Markdown table.
Keep a database as a CSV, or leave it in Notion, when you still filter, sort or group it. A Markdown table is a fixed snapshot.
What happens to images and attachments?
Images are saved next to the page in a folder with the page's name, and the Markdown points at them with relative paths such as Launch%20plan/screenshot.png. Because the cleanup script renames the folders and rewrites those paths in one pass, image links keep working after it runs.
If you move images somewhere else later, for example into one assets folder, update the paths in the Markdown at the same time. The Markdown images page shows the syntax for relative paths and for file names with spaces.
How do you check a Notion to Markdown conversion?
Before you delete anything in Notion, open a handful of pages and compare:
- Search the folder for
</to find closing HTML tags. They mark the callouts and any other blocks Notion wrote as HTML; keep them or rewrite them as quotes. - Click a few internal links to confirm they open the right file.
- Open two or three pages with images and confirm the files load.
- Compare a database CSV with the Notion view to confirm the rows and columns you need are present.
- Keep the original zip until you have used the notes for a while.
Common questions
Can you export only part of a database?
Yes. Because Markdown & CSV export writes the database's current view, filter or sort that view in Notion first, then export. Rows hidden by the filter are left out of the CSV, which is a quick way to move one project's tasks without the rest.
Can you put the exported files back into Notion?
Notion's help says a full workspace export can't be uploaded to rebuild the workspace. Single Markdown and CSV files can be brought in again through Notion's import option, but they arrive as new pages, without the links and database relations they had before.
Notion pages in Noteline
Noteline, which we make, is one place to read and edit the cleaned folder: choose File > Open Folder… (Cmd+O on a Mac, Ctrl+O on Windows and Linux) and the .md files appear in the sidebar, with tables shown as an editable grid. CSV files stay out of the sidebar list. For a single page, you can also copy it in Notion and paste into an empty Noteline note, which converts the formatted text on the clipboard to Markdown. Images linked in a note show their alt text rather than the picture, so check them in the original page or another viewer.