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 🙏

© 2025 – Pkg Stats / Ryan Hefner

git2pdf

v2.4.0

Published

A CLI tool for generating a PDF document from a GitHub repository

Readme

git2pdf

A powerful CLI tool for generating PDF documents from GitHub repositories with enhanced functionality.

What's New in 2.4.0

🎨 Improved Code Formatting

We've completely rewritten the syntax highlighting parser to fix a critical bug that caused code to render as an unreadable blob. PDFs now display beautifully formatted code with proper spacing, indentation, and syntax highlighting!

Improved Code Formatting

Key improvements:

  • ✅ Proper whitespace and token spacing preserved
  • ✅ Correct indentation maintained
  • ✅ Syntax highlighting colors applied accurately
  • ✅ Line numbers aligned properly
  • ✅ Sequential token order matches source code

Overview

git2pdf is a versatile command-line tool designed to transform GitHub repositories into well-formatted, visually engaging PDF files. This tool automates the process of cloning repositories and parsing code files, serving various use cases including:

  • Code reviews and documentation
  • Offline reference materials
  • Teaching materials
  • Technical documentation
  • Code archiving
  • Integration with AI systems

Installation and Usage

git2pdf can be installed using NPM:

npm install -g git2pdf

Or used directly with NPX:

npx git2pdf

Usage

git2pdf [repository] [options]

Options

  • -l, --local: Use a local repository
  • -o, --output <file>: Output file name (default: output.pdf)
  • -d, --dir <directory>: Output directory for individual PDFs (default: ./output)
  • -f, --file <path>: Specific file or directory path within the repository to process
  • --line-numbers: Add line numbers to code in PDF
  • --highlighting: Add syntax highlighting in PDF
  • --page-numbers: Add page numbers to PDF
  • --remove-comments: Remove comments from code
  • --remove-empty: Remove empty lines
  • --split: Generate one PDF per file
  • --keep-repo: Keep cloned repository after processing
  • -h, --help: Display help information
  • -V, --version: Display version number

Examples

Generate a PDF from a GitHub repository:

git2pdf https://github.com/user/repo

Generate a PDF with line numbers and syntax highlighting:

git2pdf https://github.com/user/repo --line-numbers --highlighting

Use a local repository:

git2pdf -l ./my-local-repo --output my-docs.pdf

Create separate PDFs for each file:

git2pdf https://github.com/user/repo --split --dir ./output

Process only a specific file or directory:

git2pdf https://github.com/user/repo --file src/components

Configuration

git2pdf automatically ignores certain file types and directories (e.g., .png, .git).

To customize the files and directories to ignore, you can add a git2pdf.ignore file to the root of your repository:

{
  "ignoredFiles": ["tsconfig.json", "dist", "node_modules"],
  "ignoredExtensions": [".raw"]
}

Requirements

  • Node.js >= 18.0.0
  • Git (for non-local repositories)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

This project is a fork of the original [repo2pdf](https://github.com/ BankkRoll/repo2pdf) by BankkRoll, with enhanced CLI functionality and improvements.

License

This project is licensed under the MIT License - see the LICENSE file for details.