Paste to Markdown

A tool to convert rich text or web articles into Markdown format.

Purpose

Two input modes:

  1. Rich text: Copy formatted text from a website, paste here, get Markdown
  2. URL: Paste an article URL, tool fetches and extracts the main content as Markdown

Supported URL sources:

Output Modes

Copy Mode (default)

Command Mode

Prefix Feature

Supported Variables

Variable Description
{author} Slugified author name
{title} Slugified article title
{date} Article date as YYYY.MM.DD
{year} Article year (4 digits)
{month} Article month (2 digits)
{day} Article day (2 digits)
{domain} Slugified source domain (without www)

Example output (with prefix {author}):

printf '%s' 'title: How to Build a Web App
author: John Doe
date: 2026-01-18
source: https://example.com

Content here...' > "john-doe.how-to-build-a-web-app.md"

Example output (without prefix):

printf '%s' 'title: How to Build a Web App
author: John Doe
date: 2026-01-18
source: https://example.com

Content here...' > "how-to-build-a-web-app.md"

UI Components

Header Bar

State 1: Empty (Initial)

State 2: Loading (URL only)

State 3: Result

Dependencies

Library Version Purpose
spellcaster 6.0.0 Reactive state management and hyperscript
turndown 7.1.2 Convert HTML to Markdown
@mozilla/readability 0.5.0 Extract article content from web pages
prismjs 1.29.0 Markdown/bash syntax highlighting

Key Functions

handlePaste(event)

isUrl(text)

fetchArticle(url)

isTwitterUrl(url)

fetchTwitterContent(url)

extractSubstackContent(html)

extractDate(doc, article)

extractAuthor(doc, article)

slugify(text)

buildMarkdown(article)

buildFileCommand(prefix, filename, markdown)

generateFilename(title)

resolvePrefix(template, article)

Output format:

title: Article Title
author: John Doe
date: 2026-01-18
source: https://example.com/article

Article content...

convertToMarkdown(html)

selectAllContent(element)

highlightMarkdown(code)

Copy event handler

Article Extraction Algorithm

Uses Mozilla's Readability.js (Firefox Reader View) which:

  1. Clones the DOM - works on a copy to avoid mutations
  2. Removes unlikely candidates - elements matching: banner, sidebar, nav, footer, header, ad, comment, social, share, related, popup, modal
  3. Scores candidates - evaluates <article>, <main>, <div>, <section> by:
    • Paragraph count and text length
    • Text-to-link ratio (low link density = better)
    • Presence of semantic tags
  4. Selects top candidate - highest scoring element
  5. Cleans result - removes remaining noise

False Positive Reduction

Technique What it catches
Prefer <article> and <main> tags Sites using semantic HTML
Penalize high link-density elements Navigation menus, related links
Blacklist class/id patterns Sidebars, ads, comments, social buttons
Minimum text length threshold Prevents selecting tiny fragments
Ignore hidden elements Modals, popups, lazy content
Text-to-markup ratio scoring Favors content-heavy elements

User Workflows

Rich Text Workflow

  1. User copies text from a website (Ctrl+C)
  2. User opens this tool
  3. User pastes (Ctrl+V)
  4. Markdown appears, fully selected
  5. User copies (Ctrl+C)
  6. Press Escape to reset

URL Workflow

  1. User copies article URL
  2. User opens this tool
  3. User pastes URL (Ctrl+V)
  4. Loading indicator appears
  5. Article is fetched and extracted
  6. Markdown appears, fully selected
  7. User copies (Ctrl+C)
  8. Press Escape to reset