๐Ÿ“ฆ jokull / markdown-ig-story

Convert markdown to Instagram story-sized PNG images (1080x1920px)

โ˜… 1 stars โ‘‚ 1 forks ๐Ÿ‘ 1 watching
๐Ÿ“ฅ Clone https://github.com/jokull/markdown-ig-story.git
HTTPS git clone https://github.com/jokull/markdown-ig-story.git
SSH git clone git@github.com:jokull/markdown-ig-story.git
CLI gh repo clone jokull/markdown-ig-story
Loading files...
๐Ÿ“„ README.md

markdown-ig-story

Convert markdown to Instagram story-sized PNG images (1080x1920px) perfect for sharing on social media.

Includes both a web UI and a CLI tool.

Requirements

  • Bun (for web UI) or Node.js (for CLI only)
  • Pandoc - For markdown to PDF conversion
  • Weasyprint - PDF engine for pandoc
  • Poppler - For PDF to image conversion (provides pdftoppm)
On macOS, you can install all requirements with Homebrew:

brew install bun pandoc weasyprint poppler

Installation

bun install
# or
npm install

Usage

Web UI (Recommended)

Start the web server:

bun run dev

Then open http://localhost:3000 in your browser.

Features:

  • ๐ŸŽจ Beautiful, modern interface
  • ๐Ÿ“ Live markdown editing
  • ๐Ÿ“ฆ Downloads ZIP file with all images
  • ๐Ÿ”„ Hot reloading during development

CLI

Build and use the command-line tool:

npm run build:cli
cat example.md | npm start -- --output ./output --prefix my-story

Options

  • -o, --output <directory> - Output directory for PNG files (default: current directory)
  • -p, --prefix <prefix> - Filename prefix for output images (default: "story")

How it works

  • Takes markdown from stdin
  • Converts markdown to styled PDF using Pandoc + Weasyprint with Instagram story dimensions (1080x1920px)
  • PDF engine naturally handles page breaks at appropriate content boundaries
  • Each PDF page is converted to a PNG image using pdftoppm
  • Saves as numbered PNG files (story-01.png, story-02.png, etc.)

Features

  • โœ… Automatic content splitting for long markdown
  • โœ… Clean, readable default styling
  • โœ… Support for headings, paragraphs, lists, blockquotes, and code blocks
  • โœ… Optimized for mobile viewing
  • โœ… Simple CLI interface

Styling

The tool uses a default CSS stylesheet optimized for social media consumption. Font sizes, spacing, and colors are carefully chosen for readability on mobile devices.

Project Structure

markdown-ig-story/
โ”œโ”€โ”€ src/              # Core library (CLI + shared code)
โ”‚   โ”œโ”€โ”€ index.ts      # CLI entry point
โ”‚   โ”œโ”€โ”€ renderer.ts   # Markdown โ†’ Image converter
โ”‚   โ””โ”€โ”€ styles.css    # Instagram story CSS styling
โ”œโ”€โ”€ web/              # Web UI frontend (React)
โ”‚   โ”œโ”€โ”€ App.tsx       # Main React component
โ”‚   โ”œโ”€โ”€ main.tsx      # React entry point
โ”‚   โ””โ”€โ”€ styles.css    # Tailwind CSS
โ”œโ”€โ”€ public/           # Static assets
โ”‚   โ””โ”€โ”€ index.html    # HTML template
โ”œโ”€โ”€ server.ts         # Bun fullstack server
โ”œโ”€โ”€ bunfig.toml       # Bun config (Tailwind plugin)
โ””โ”€โ”€ package.json      # Dependencies and scripts

Development

# Start web UI dev server
bun run dev

# Build CLI tool
npm run build:cli

# Type check
npm run typecheck

# Format code
npm run format

# Lint
npm run lint:fix

Limitations

  • Tables and images in markdown are not supported
  • Custom styling/theming is not available in this version
  • Output is fixed to 1080x1920px (Instagram story format)

Example

echo "# My Story

This is a paragraph with **bold** text.

## Subsection

- Item 1
- Item 2
- Item 3

> A quote

Some code: \`const x = 42\`
" | npm start -- --output ./stories --prefix my-blog

This would create my-blog-01.png, my-blog-02.png, etc. in the ./stories directory.