Skip to main content

PR2MD - Pull Request to Markdown

Python 3.13+ PyPI version License: CRL

PR2MD is a powerful command-line tool that extracts GitHub Pull Request and Issue data and converts it into comprehensive, well-formatted Markdown documents. Perfect for documentation, archiving, code reviews, or offline analysis of pull requests and issues.

Features

  • 📥 Complete PR & Issue Data Extraction: Retrieves all PR and Issue details including metadata, description, labels, and timestamps
  • 💬 Full Conversation Thread: Captures all comments and discussions in chronological order
  • ✅ Review Information: Includes all code reviews with approval status and reviewer comments (PRs only)
  • 💻 Code Comments: Extracts inline review comments with their associated code context (PRs only)
  • 📊 Change Statistics: Displays files changed, additions, deletions, and commit information (PRs only)
  • 🔍 Complete Diffs: Includes the full unified diff of all changes (PRs only)
  • 🎨 Beautiful Formatting: Generates clean, readable Markdown with proper structure and syntax highlighting
  • ⚡ Fast & Efficient: Uses the official GitHub REST API with proper error handling
  • 🔒 Type-Safe: Written in Python with comprehensive type annotations

Installation

The easiest way to install PR2MD is directly from PyPI:

pip install PR2MD

That's it! The pr2md command will be available in your terminal.

From Source

Alternatively, you can install from source for development or to get the latest unreleased features:

# Clone the repository
git clone https://github.com/tboy1337/PR2MD.git
cd PR2MD

# Install dependencies
pip install -r requirements.txt

# Install the package
pip install -e .

Requirements

  • Python 3.13 or higher
  • requests library (automatically installed with pip)

Quick Start

After installing via pip, you can immediately start using PR2MD:

# Extract a PR by URL (saves to PR-123.md)
pr2md https://github.com/owner/repo/pull/123

# Extract an Issue by URL (saves to Issue-456.md)
pr2md https://github.com/owner/repo/issues/456

# Save to a custom filename
pr2md https://github.com/owner/repo/pull/123 -o output.md

# Output to console/stdout
pr2md https://github.com/owner/repo/pull/123 -o

Usage

Basic Usage

Extract a PR using its URL (automatically saves to PR-123.md):

pr2md https://github.com/owner/repo/pull/123

Extract an Issue using its URL (automatically saves to Issue-456.md):

pr2md https://github.com/owner/repo/issues/456

Or specify the owner, repository, type, and number separately:

pr2md owner repo pr 123
pr2md owner repo issue 456

Save to Custom Filename

Output the Markdown to a custom filename:

pr2md https://github.com/owner/repo/pull/123 -o pr-details.md
pr2md owner repo pr 123 --output pr-analysis.md
pr2md owner repo issue 456 --output issue-report.md

Output to Console

Output to stdout instead of saving to a file:

pr2md https://github.com/owner/repo/pull/123 -o
pr2md owner repo pr 123 --output
pr2md owner repo issue 456 --output

Verbose Logging

Enable detailed logging for debugging:

pr2md https://github.com/owner/repo/pull/123 --verbose

Help

View all available options:

pr2md --help

Output Format

The generated Markdown document includes:

For Pull Requests:

1. PR Header

  • PR number, title, and status (Open/Closed/Merged)
  • Author information with GitHub profile link
  • Creation, update, closed, and merged timestamps
  • Base and head branch information with commit SHAs
  • Labels (if any)

2. Description

  • The full PR description/body

3. Changes Summary

  • Number of files changed
  • Line additions and deletions

4. Code Diff

  • Complete unified diff of all changes
  • Syntax-highlighted code blocks

5. Conversation Thread

  • All comments from the PR discussion
  • Chronologically sorted
  • Author attribution and timestamps
  • Links back to GitHub

6. Reviews

  • All submitted reviews
  • Review state (Approved ✅, Changes Requested 🔴, Commented 💬, etc.)
  • Review comments and timestamps

7. Review Comments (Code Comments)

  • Inline code review comments
  • Grouped by file
  • Includes code context (diff hunk)
  • Reply chains preserved

For Issues:

1. Issue Header

  • Issue number, title, and status (Open/Closed)
  • Author information with GitHub profile link
  • Creation, update, and closed timestamps
  • Labels (if any)

2. Description

  • The full issue description/body

3. Conversation Thread

  • All comments from the issue discussion
  • Chronologically sorted
  • Author attribution and timestamps
  • Links back to GitHub

Example

# Extract PR #42 from the PR2MD repository (saves to PR-42.md)
pr2md tboy1337 PR2MD pr 42

# Extract Issue #10 from the PR2MD repository (saves to Issue-10.md)
pr2md tboy1337 PR2MD issue 10

This creates files containing all the PR/Issue information in beautifully formatted Markdown documents.

If you want a custom filename:

pr2md tboy1337 PR2MD pr 42 -o pr-42-analysis.md
pr2md tboy1337 PR2MD issue 10 -o issue-10-report.md

GitHub API Rate Limiting

The tool uses the GitHub REST API without authentication by default. GitHub imposes rate limits:

  • Unauthenticated requests: 60 requests per hour
  • Authenticated requests: 5,000 requests per hour

For most use cases, unauthenticated access is sufficient as the tool makes only a few API calls per PR. If you encounter rate limiting issues, the tool will provide clear error messages.

Future Enhancement: Authentication support is planned for a future release to enable higher rate limits and access to private repositories.

Limitations

  • Currently supports only public GitHub repositories (authentication coming soon)
  • Rate limited by GitHub API (60 requests/hour without authentication)
  • Requires internet connection to fetch data
  • Large PRs with extensive diffs may generate very large Markdown files
  • Issues can be downloaded, but PRs accessed via the /issues/ endpoint will show as issues (use /pull/ or explicit pr type for PRs)

License

This project is licensed under the CRL License - see LICENSE.md for details.

Metadata

Release files for PR2MD 1.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PR2MD 1.0.8
File Size Uploaded Provenance Actions
pr2md-1.0.8.tar.gz 34.9 kB Without provenance Details for pr2md-1.0.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for PR2MD 1.0.8
File Interpreter ABI Platform Actions
pr2md-1.0.8-py3-none-any.whl Python 3 none any Details for pr2md-1.0.8-py3-none-any.whl

Total release size: 56.3 kB

Release files / pr2md-1.0.8.tar.gz

Download URL pr2md-1.0.8.tar.gz
Size 34.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6e7c905050290338392f312c65c1b9d8e5b0c2eaa6bd8e00e82b624cbdf5ee7b
BLAKE2b-256 checksum
How to use checksums
17746aa9bab9c0740f1ef66a1a3ae73672a765ccac18ff295dc57f201b0b67b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / pr2md-1.0.8-py3-none-any.whl

Download URL pr2md-1.0.8-py3-none-any.whl
Size 21.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1116ea00f13f3f9cc89c6d6c2a0ebcf0a8933c2f018daf012550cc9369aee15e
BLAKE2b-256 checksum
How to use checksums
3fcadbc2ce23240eea6a8f9b6fc45b64631b2c3a6147e0dec65dd3e717cb1a91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Security for PR2MD 1.0.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page