npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

md-notion-sync

v1.0.1

Published

Sync markdown files to Notion pages.

Downloads

5

Readme

md-notion-sync

A TypeScript/Node.js package to sync markdown files to Notion pages with proper formatting support.

Features

  • Rich Formatting: Supports headers, bold, italic, code blocks, lists, tables, quotes, and links
  • 🧹 Smart Link Filtering: Automatically filters out relative links, anchor links, and images
  • 🔄 Batch Processing: Handles large documents with efficient batch uploads
  • 🎯 Type Safety: Built with TypeScript for better development experience
  • 📦 Multiple Interfaces: Use as CLI tool, programmatic API, or GitHub Action
  • 🚀 Easy Setup: Simple configuration with environment variables

Installation

npm install md-notion-sync

For global CLI usage:

npm install -g md-notion-sync

Quick Start

CLI Usage

  1. Initialize configuration:
md-notion-sync init
  1. Edit the generated .env file with your Notion token:
NOTION_TOKEN=your_notion_integration_token_here
  1. Sync a markdown file:
md-notion-sync sync -f README.md -p your_notion_page_id

Programmatic Usage

import { syncMarkdownToNotion } from 'md-notion-sync';

await syncMarkdownToNotion({
  notionToken: 'your_notion_token',
  pageId: 'your_page_id', 
  filePath: './README.md',
  clearExisting: true // optional, defaults to true
});

Advanced Usage

import { NotionSync, MarkdownToNotion } from 'md-notion-sync';

// Create converter and sync instances
const converter = new MarkdownToNotion();
const sync = new NotionSync('your_token');

// Convert markdown to Notion blocks
const blocks = converter.convert(markdownContent);

// Add to Notion page
await sync.addBlocksToPage('page_id', blocks);

GitHub Action Usage

Create .github/workflows/sync-readme.yml:

name: Sync README to Notion
on:
  push:
    paths: ['README.md']

jobs:
  sync:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      
      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: '18'
      
      - name: Install package
        run: npm install -g md-notion-sync
      
      - name: Sync to Notion
        run: md-notion-sync sync -f README.md -p ${{ secrets.NOTION_PAGE_ID }}
        env:
          NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}

Configuration

Environment Variables

  • NOTION_TOKEN: Your Notion integration token (required)
  • NOTION_PAGE_ID: Default page ID to sync to (optional)

CLI Options

md-notion-sync sync [options]

Options:
  -f, --file <path>     Path to markdown file (required)
  -p, --page-id <id>    Notion page ID (required)
  -t, --token <token>   Notion API token (or use NOTION_TOKEN env var)
  --no-clear            Don't clear existing content before syncing
  -h, --help            Display help for command

Supported Markdown Features

| Feature | Support | Notes | |---------|---------|-------| | Headers (H1-H3) | ✅ | Converted to Notion heading blocks | | Bold text | ✅ | Rich text formatting | | Italic text | ✅ | Rich text formatting | | Inline code | ✅ | Rich text formatting | | Code blocks | ✅ | With language syntax highlighting | | Lists (ordered/unordered) | ✅ | Nested lists supported | | Tables | ✅ | With headers and formatting | | > Blockquotes | ✅ | Converted to quote blocks | | Links | ✅ | External links only | | Images | ❌ | Filtered out (not supported by Notion API) | | Horizontal rules | ✅ | Converted to divider blocks |

Getting Your Notion Token

  1. Go to Notion Developers
  2. Click "Create new integration"
  3. Give it a name and select your workspace
  4. Copy the "Internal Integration Token"
  5. Share your target page with the integration

Getting a Notion Page ID

The page ID is the string of characters after your workspace name and before any query parameters:

https://www.notion.so/workspace/Page-Title-HERE_IS_THE_PAGE_ID

API Reference

syncMarkdownToNotion(options)

Main sync function.

Parameters:

  • options.notionToken (string): Notion API token
  • options.pageId (string): Target Notion page ID
  • options.filePath (string): Path to markdown file
  • options.clearExisting (boolean, optional): Clear existing content first (default: true)

MarkdownToNotion

Converter class for transforming markdown to Notion blocks.

Methods:

  • convert(markdown: string): NotionBlock[] - Convert markdown string to Notion blocks

NotionSync

Notion API wrapper class.

Methods:

  • clearPageContent(pageId: string): Promise<void> - Clear all blocks from a page
  • addBlocksToPage(pageId: string, blocks: NotionBlock[]): Promise<void> - Add blocks to a page
  • syncMarkdownToNotion(options: SyncOptions): Promise<void> - Full sync operation

Error Handling

The package includes comprehensive error handling for:

  • Invalid Notion tokens
  • Missing or inaccessible files
  • Network failures
  • Notion API rate limits
  • Invalid page IDs