Skip to content

NotionExporter is a Windows command-line tool built with .NET that exports data from the Notion API into JSON format. It supports exporting databases, pages, blocks, and allows for custom filters and sorting via query files.

License

Notifications You must be signed in to change notification settings

patriksima/NotionExporter

NotionExporter

build status codeql status unit tests status

NotionExporter is a Windows command-line tool built with .NET that exports data from the Notion API into JSON format. It supports exporting databases, pages, blocks, and allows for custom filters and sorting via query files.


πŸš€ Features

  • βœ… Export Notion databases, pages, and blocks
  • βœ… Output to JSON file or standard output
  • βœ… Support for Notion filters and sorts
  • βœ… Accepts Notion API token from CLI, environment variables, config file, or secure prompt
  • βœ… Clean and modular CLI built with Spectre.Console.Cli

🧩 Download

Download the latest release from the Releases page.

  • βœ… Self-contained executable for Windows
  • βœ… No .NET installation required

πŸ› οΈ Requirements


βš™οΈ Build & Run

  1. Build the application:
dotnet publish -c Release
  1. Run it:
NotionExporter.cli.exe [command] [options]

πŸ“¦ Usage

πŸ”Έ Export a database to a file

NotionExporter.cli.exe databases export --id 1234abcd --output data.json

πŸ”Έ Export a database to standard output

NotionExporter.cli.exe databases export --id 1234abcd

πŸ”Έ Use a custom filter query

NotionExporter.cli.exe databases export --id 1234abcd --filter-file query.json

Example query.json:

{
  "filter": {
    "property": "Date",
    "date": {
      "this_week": {}
    }
  },
  "sorts": [
    {
      "property": "Name",
      "direction": "ascending"
    }
  ]
}

πŸ” Getting a Notion API Token

  1. Create a Notion integration
  2. Obtain your Internal Integration Token
  3. Use the token in one of the following ways:
    • As CLI argument: --token <your-token>
    • As environment variable: NOTION_API_TOKEN
    • Or enter it securely via prompt if not provided

πŸ§ͺ PowerShell Example: Filter and Format Output

NotionExporter.cli.exe databases export --id 1234abcd |
    ConvertFrom-Json |
    % { $_.results } |
    % { [PSCustomObject]@{ Name = $_.properties.Name.title[0].plain_text } } |
    Format-Table -AutoSize

πŸ“‚ Configuration (Optional)

You can provide configuration via:

  • appsettings.json
  • Environment variables

🀝 Contributing

Pull requests are welcome!
Feel free to open issues for bugs, suggestions, or feedback.


πŸ“„ License

This project is licensed under the MIT License. See LICENSE for details.

About

NotionExporter is a Windows command-line tool built with .NET that exports data from the Notion API into JSON format. It supports exporting databases, pages, blocks, and allows for custom filters and sorting via query files.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •