sb2n
Helpfeel Cosense (Scrapbox) to Notion Migration Tool
Installation
pip install sb2n
# or, (use as CLI only)
pipx install sb2n
Usage
1. Set up environment variables
Create a .env file in your project directory. (See: .env.example)
2. Prepare Notion Database
Create a database in Notion with the following properties:
- Title (Title) - Page title
- Scrapbox URL (URL) - Link to original Scrapbox page
- Created Date (Date) - Original creation date
- Tags (Multi-select) - Tags from Scrapbox
3. Run migration
# Basic migration (using .env file)
sb2n migrate
# Specify custom .env file
sb2n migrate --env-file /path/to/.env
# Specify credentials directly via command line options
sb2n migrate -P your-project -S your-sid -N secret_token -D database-id
# Mix .env and options (options take precedence)
sb2n migrate --env-file .env -P override-project
# Dry run (no actual changes)
sb2n migrate --dry-run
# Migrate only first 10 pages
sb2n migrate -n 10
# Skip pages that already exist in Notion
sb2n migrate --skip
# Combine options: dry run with limit and skip existing
sb2n migrate --dry-run -n 5 --skip
# Enable verbose logging
sb2n -v migrate
Common Options (for all commands)
-P, --project: Scrapbox project name (overridesSCRAPBOX_PROJECTin .env)-T, --pat: Scrapbox personal access token (overridesSCRAPBOX_PATin .env)-S, --sid: Scrapbox connect.sid cookie (overridesSCRAPBOX_COOKIE_CONNECT_SIDin .env)-N, --ntn: Notion integration token (overridesNOTION_API_KEYin .env)-D, --db: Notion database ID (overridesNOTION_DATABASE_IDin .env)--env-file: Path to .env file (default:.env)-v, --verbose: Enable verbose logging
Note: When both .env and command line options are specified, command line options take precedence.
Note: Scrapbox authentication needs either a personal access token or a connect.sid cookie.
The personal access token is recommended, and takes precedence when both are set.
4. Restore internal links
After migration, restore Scrapbox internal links ([PageName] format) to actual Notion page mentions:
# Restore links in all pages
sb2n restore-link
# Dry run (preview changes without applying)
sb2n restore-link --dry-run
# Restore links in specific pages only
sb2n restore-link --pages "HomePage,Getting Started"
# Enable verbose logging
sb2n -v restore-link
Appendix 1. Export as Markdown with images
Export Scrapbox pages to Markdown format with downloaded images. Images are saved in an assets/ directory and referenced with relative paths in the Markdown files.
# Export to default directory (./out)
sb2n export
# Specify output directory
sb2n export -d /path/to/output
# Limit number of pages to export
sb2n export --limit 10
# Combine options
sb2n export -d ./my-export --limit 5
# Export as plain Scrapbox format
sb2n export --f txt
# Enable verbose logging
sb2n -v export
Structure of extracted data
output-dir/project-name/
├── assets/ # Downloaded images
│ ├── abc123def456.png
│ ├── 789ghijk012.jpg
│ └── ...
├── page1.md # Markdown files
├── page2.md
└── ...
Development
See docs/specification.md for detailed specifications.
License
Metadata
Release files for sb2n 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sb2n-0.4.0.tar.gz | 39.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sb2n-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 83.0 kB
Release files / sb2n-0.4.0.tar.gz
| Download URL | sb2n-0.4.0.tar.gz |
|---|---|
| Size | 39.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a48b7c4d152f432f6c5a33d754bdda65a326eb973d9829ee772753feed00285e
|
|
BLAKE2b-256 checksum How to use checksums |
d366c9f56f97bc519401f4cbf6049f09494d6930da0461816b1bfb5158800637
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / sb2n-0.4.0-py3-none-any.whl
| Download URL | sb2n-0.4.0-py3-none-any.whl |
|---|---|
| Size | 43.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
896b5b1f7926997e8e04c6e54803dc5e196415673314d0e142761e41dd470db3
|
|
BLAKE2b-256 checksum How to use checksums |
ba3ef0801cc781ccbfc825fd7d4c3819bdc97f6f2f107521de126b9ea4806169
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|