Skip to main content

Overview

The Web2MD CLI lets you convert any URL to clean Markdown directly from your terminal. Pipe output to LLMs, batch-process URL lists, or ingest content into your Obsidian vault — all without opening a browser.
The CLI requires Node.js 18+. Run node -v to check your version.

Installation

No installation needed — just run with npx:
The official npm package is web2md-cli. The package named web2md belongs to an unrelated project, so do not run npx web2md or npm install -g web2md.
Or install globally for faster startup:

Modes

Web2MD CLI operates in three modes depending on your configuration:

Local

Default mode. No API key required. Fetches pages and converts locally. Works for most public websites.

Server

With API key. Set WEB2MD_API_KEY to unlock Reddit, Fandom/Wikia, and other restricted sites that require server-side handling.

Bridge

With --bridge flag. Uses your Chrome extension to fetch JS-rendered or login-protected pages that static fetching cannot reach.

Flags

Commands

Besides converting URLs, the CLI has two subcommands for authentication and Library sync:

login

Starts a browser-based device authorization flow: the CLI opens https://web2md.org and shows a code to approve. Once approved, your API key is saved to ~/.web2md/config.json — no need to export WEB2MD_API_KEY in every shell. The MCP server reads from the same file, so logging in once here also authenticates MCP tool calls. Prefer to paste a key directly instead of the browser flow?
This prompts for a key (w2m_...) on stdin and saves it the same way. Get a key from the dashboard.

sync

Syncs your Library — every page you’ve saved via the extension, dashboard, or API — to a local directory as Markdown files with frontmatter, organized by tag. Requires being logged in (or WEB2MD_API_KEY set). Sync is incremental by default: it tracks a cursor in <dir>/.web2md-sync.json and only pulls new items on subsequent runs. Point Obsidian (or any Markdown-reading tool) at the target directory to browse your Library as notes.

Environment variables

Add these to your shell profile (~/.zshrc or ~/.bashrc) so they persist across sessions:

Usage examples

Basic conversion

Prints Markdown to stdout.

Pipe to an LLM

Save to file

The --meta flag prepends YAML frontmatter with title, source URL, word count, token count, reading time, and date.

Batch from file

Create a file urls.txt:
Then run:
Each URL is saved as a separate .md file in the ./research directory. Filenames contain a short URL hash, so pages with identical titles do not overwrite one another. Re-run an interrupted batch with --resume. By default, any failed URL makes the command return a non-zero exit code. Use --allow-partial only when partial results should count as success.

Obsidian vault ingestion

This saves each page to ~/Documents/MyVault/raw/ and updates ~/Documents/MyVault/INDEX.md with links to all converted pages.

Reddit with API key

Reddit requires a valid API key. Without one, Reddit URLs will fail due to Reddit’s bot restrictions.

Bridge mode

Use the Chrome extension to handle JS-rendered or login-protected pages:
Bridge mode requires the Web2MD Chrome extension to be installed and Chrome to be running. The CLI communicates with the extension via Chrome’s native messaging protocol.

JSON output

Returns structured output:
Useful for programmatic consumption or piping to jq:
With multiple URLs, --json returns one valid JSON array containing a result or error record for each URL:
For streaming pipelines, use newline-delimited JSON:

Optimized sites

Web2MD includes built-in adapters for these sites, producing cleaner output than generic conversion:
  • Wikipedia — clean article extraction, infobox handling
  • arXiv — paper abstracts and metadata
  • Hacker News — threads with comments
  • GitHub — Issues and Pull Requests
  • Stack Overflow — questions and answers
  • dev.to — blog posts
  • Medium — articles (bypasses paywall preview)
  • Substack — newsletter posts
  • OpenAI Docs — documentation pages
  • Mintlify-based docs — documentation sites built on Mintlify
  • Reddit — posts and comments (requires API key)

Common workflows

Point your AI agent’s context directory at ./context for grounded answers.
Creates an indexed, searchable research vault in Obsidian.
Removes images and links to reduce token usage when piping to LLMs.