Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

notion-export-cleaner

Clean Notion exports for import into Trilium Notes, Obsidian, Joplin, and other note-taking applications.

Notion appends 32-character hash identifiers to every exported filename and directory. This breaks filenames, folder names, and internal links when importing into other tools. This script strips those hashes and fixes all internal references automatically.

What it does

  1. Extracts your Notion export zip (handles nested zips automatically)
  2. Recursively removes Notion hash suffixes from all filenames and directories
  3. Fixes all internal links (%20<hash> references) inside Markdown and HTML files
  4. Outputs a clean zip ready to import
  5. Preserves note hierarchy and folder structure

Before

BB f708f1d322674a1faf7e67f8c3a05a48/
  AI Products to 31497b48837a803da1d8dab26ed32fe0/
  test 1ae97b48837a80efb19bd0ec7f81e32b.html
BB f708f1d322674a1faf7e67f8c3a05a48.html

After

BB/
  AI Products to/
  test.html
BB.html

Requirements

  • Bash 3.2 or later (ships with macOS, Linux, Git Bash, WSL)
  • unzip, zip, sed, sort, grep

Installation

git clone https://github.com/<your-username>/notion-export-cleaner.git
cd notion-export-cleaner
chmod +x notion2trilium.sh

Or download notion2trilium.sh directly and make it executable.

Usage

1. Export from Notion

Go to Settings > Export in Notion. Choose Markdown or HTML format. Download the zip file.

2. Place the zip next to the script

notion-export-cleaner/
  notion2trilium.sh
  your-notion-export.zip

3. Run the script

Interactive mode -- finds all zips in the current directory and lets you pick:

./notion2trilium.sh
Found 3 zip files:

  [1] notion-export-part1.zip (12 MB)
  [2] notion-export-part2.zip (8 MB)
  [3] old-backup.zip (3 MB)

Select a file [1-3]: 1

Or pass the zip directly:

./notion2trilium.sh your-notion-export.zip

The script extracts, cleans, and produces your-notion-export-Clean.zip when finished.

4. Import into your note-taking app

  • Trilium Notes: File > Import into note > select the zip
  • Obsidian: Unzip into your vault folder
  • Joplin: File > Import > select the zip

Platform support

Platform Status
macOS Tested
Linux Supported
Windows (WSL) Supported
Windows (Git Bash) Supported

How it works

Notion exports use the format Note Title <32-char-hex-hash>.extension for files and Folder Name <32-char-hex-hash> for directories. The hash is a unique Notion block identifier.

The script:

  1. Extracts the selected zip into a working directory (unpacks nested zips if present)
  2. Walks the directory tree and identifies filenames containing a trailing 32-character hexadecimal string
  3. Renames each file/directory by removing the <hash> portion
  4. Records every hash found
  5. Walks the tree again and removes %20<hash> from all internal links in text files
  6. Zips the cleaned result and removes the working directory

Internal links in Notion exports use URL-encoded paths like Note%20Title%2031497b48837a803da1d8dab26ed32fe0. After the hash is stripped from the filename, the link must also be updated to Note%20Title so it resolves correctly.

License

MIT

About

Notion Export And Import In Any Note Taking Application

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages