Skip to main content

Export Notion pages and databases to JSON with filtering and advanced options

Project description

Notion to JSON Exporter

PyPI version Test Python 3.13+

Export your entire Notion workspace to JSON format with a simple command-line tool.

Features

  • Export all pages and databases from your Notion workspace
  • Recursive discovery of nested pages and child databases
  • Systematic traversal of nested content
  • Progress tracking with rich terminal UI
  • JSON format preserving Notion structure
  • Secure API key handling via CLI or environment variables
  • Rate-limited API calls to respect Notion's limits

Installation

From PyPI

# Using pip
pip install notion-to-json

# Using uv
uv pip install notion-to-json

# Using uvx (no installation needed)
uvx notion-to-json --api-key YOUR_API_KEY

From source

# Clone the repository
git clone https://github.com/jonatkinson/notion-to-json.git
cd notion-to-json

# Install dependencies
uv sync

Usage

Basic usage

# Export entire workspace (default)
export NOTION_API_KEY="your-integration-token"
notion-to-json

# Using command-line flag
notion-to-json --api-key "your-integration-token"

# Specify output directory
notion-to-json --output-dir ./my-exports

# Export creates:
# - exports/pages/       # Individual page JSON files
# - exports/databases/   # Individual database JSON files  
# - exports/manifest.json # Export summary and metadata

# Test API connection only
notion-to-json --test --api-key "your-integration-token"

# Search and list all pages and databases
notion-to-json --search --api-key "your-integration-token"

# List ALL pages (not just first 10) and databases
notion-to-json --list-all --api-key "your-integration-token"

# Save search results to a JSON file
notion-to-json --search --save-list "notion-content.json" --api-key "your-integration-token"

# Retrieve specific page content
notion-to-json --get-page "page-id-here" --api-key "your-integration-token"

# Save page content to file
notion-to-json --get-page "page-id-here" -o "page-content.json" --api-key "your-integration-token"

# Retrieve specific database content
notion-to-json --get-database "database-id-here" --api-key "your-integration-token"

# Save database content to file  
notion-to-json --get-database "database-id-here" -o "database-content.json" --api-key "your-integration-token"

Advanced options

# Verbose logging
notion-to-json --verbose

# Quiet mode (errors only)
notion-to-json --quiet

# Log to file
notion-to-json --log-file export.log

# Export only pages
notion-to-json --filter-type page

# Export only databases
notion-to-json --filter-type database

# Filter by title pattern (regex)
notion-to-json --include-pattern "Project.*2024"
notion-to-json --exclude-pattern "Archive|Draft"

# Export items modified after a date
notion-to-json --modified-after "2024-01-01"

# Disable recursive discovery (only export top-level items)
notion-to-json --no-recursive

# Combine filters
notion-to-json --filter-type page --include-pattern "Meeting" --modified-after "2024-06-01"

Getting a Notion API Key

  1. Go to https://www.notion.so/my-integrations
  2. Create a new integration
  3. Copy the "Internal Integration Token"
  4. Share your Notion pages/databases with the integration

Development

Setup

# Install development dependencies
make install

# Run linting
make lint

# Format code
make format

# Run tests
make test

# Run all checks
make dev

Project Structure

notion-to-json/
├── src/
│   └── notion_to_json/
│       ├── cli.py          # CLI interface
│       ├── client.py       # Notion API client
│       ├── models.py       # Data models
│       └── exporter.py     # JSON export logic
└── tests/                  # Test suite

Roadmap

  • Phase 1: Project setup and structure
  • Phase 2: Notion API client implementation
  • Phase 3: Content discovery (pages & databases)
  • Phase 4: Full content retrieval
  • Phase 5: JSON export functionality
  • Phase 6: CLI enhancements and distribution

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

notion_to_json-1.1.0.tar.gz (33.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

notion_to_json-1.1.0-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file notion_to_json-1.1.0.tar.gz.

File metadata

  • Download URL: notion_to_json-1.1.0.tar.gz
  • Upload date:
  • Size: 33.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for notion_to_json-1.1.0.tar.gz
Algorithm Hash digest
SHA256 ef2108f03407f57282a1746c50f0db1e4d3d23920760eabecdc893871e25292e
MD5 5a11377ff7fad31815f9ba6934cf2bce
BLAKE2b-256 4e9d55f9c1fd716e7ed08162b385019542d8d8eafe2c9f8f77e428c4c6eac688

See more details on using hashes here.

Provenance

The following attestation bundles were made for notion_to_json-1.1.0.tar.gz:

Publisher: publish.yml on jonatkinson/notion-to-json

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file notion_to_json-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: notion_to_json-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for notion_to_json-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ac17652500d749029f96c04f1a19df4bb24fbe96068f3c96eb2ce79160a0c6f7
MD5 823a9ad6137d4abde2aed7fdc108a694
BLAKE2b-256 568990c5b3a9576f3e36db7760b155b0894375dc23a8be6a7b2bc834c30e316d

See more details on using hashes here.

Provenance

The following attestation bundles were made for notion_to_json-1.1.0-py3-none-any.whl:

Publisher: publish.yml on jonatkinson/notion-to-json

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page