Overview
repo2pdf is a command-line tool that converts GitHub repositories into formatted PDF documents. This page provides a complete reference for all available commands and options.Command
Alternative Execution Methods
NPX (Recommended)
Local Installation
Interactive Prompts
When you runrepo2pdf, you’ll be guided through an interactive configuration process:
Repository Source
Choose between using a local repository or cloning from GitHub.Choices:
No- Clone from a GitHub URLYes- Use a local repository path
Local Repository Path
The full filesystem path to your local repository.When shown: Only appears if you select “Yes” for local repositoryValidation: Path must exist on your filesystemExample:
/home/user/projects/my-repoGitHub Repository URL
The GitHub repository URL to clone and convert.When shown: Only appears if you select “No” for local repositoryFormat: Must be a valid GitHub URL:
https://github.com/username/repositoryExample: https://github.com/BankkRoll/repo2pdfFeatures Selection
Multi-select checkbox for PDF generation features.Available options:
Add line numbers
Add line numbers
Adds line numbers to the left side of all code in the PDF. The line numbers are automatically padded to align properly based on the total number of lines.Use case: Code reviews, teaching, referencing specific lines
Add highlighting
Add highlighting
Applies syntax highlighting to code based on file extension. Uses highlight.js to detect and colorize code syntax.Supported languages: JavaScript, TypeScript, Python, Java, C++, and 180+ other languages
Add page numbers
Add page numbers
Adds page numbers at the bottom center of each page in the format “Page: X of Y”.Note: Only available when generating a single PDF (not with “One PDF per file”)
Remove comments
Remove comments
Strips all comments from code files before adding to the PDF. Uses the
strip-comments library to remove:- Single-line comments (
//,#, etc.) - Multi-line comments (
/* */,""" """, etc.)
Remove empty lines
Remove empty lines
Removes blank lines from code files to create more compact output.Use case: Reduce PDF page count, maximize code density
One PDF per file
One PDF per file
Generates a separate PDF for each file in the repository instead of a single combined PDF.Output: Creates a folder with individual PDFs named after each source file
Output File Name
The name of the generated PDF file.When shown: Only when “One PDF per file” is NOT selectedDefault:
output.pdfExample: my-project-documentation.pdfOutput Folder Name
The folder where individual PDF files will be saved.When shown: Only when “One PDF per file” IS selectedDefault:
./outputExample: ./project-pdfsKeep Cloned Repository
Whether to keep the cloned repository on your filesystem after PDF generation.When shown: Only when cloning from GitHub (not for local repositories)Choices:
No- Delete the cloned repository after PDF generationYes- Keep the repository in./tempRepodirectory
NoConfiguration File
repo2pdf.ignore
Create arepo2pdf.ignore file in the root of your repository to customize which files and directories are excluded from the PDF.
File format: JSON
Example:
Array of file names or directory names to exclude.Example:
["package-lock.json", "node_modules", "dist", ".env"]Array of file extensions to exclude (including the dot).Example:
[".raw", ".log", ".tmp", ".cache"]Default Exclusions
repo2pdf automatically excludes common files and directories: Default excluded directories:.gitnode_modules.nextdistbuild
- Images:
.png,.jpg,.jpeg,.gif,.svg,.ico - Archives:
.zip,.tar,.gz - Binaries:
.exe,.dll,.so,.dylib - Media:
.mp4,.mp3,.wav
Requirements
Minimum version: Node.js 18.0.0 or higherCheck your version:
Required for: Cloning repositories from GitHubNot required for: Local repositoriesCheck if installed:
Dependencies
repo2pdf uses the following core dependencies:| Package | Version | Purpose |
|---|---|---|
pdfkit | ^0.13.0 | PDF generation |
highlight.js | ^11.9.0 | Syntax highlighting |
simple-git | ^3.18.0 | Git operations |
inquirer | ^9.2.6 | Interactive CLI prompts |
chalk | ^5.2.0 | Terminal styling |
ora | ^6.3.1 | Loading spinners |
prettier | ^3.0.3 | Code formatting |
strip-comments | ^2.0.1 | Comment removal |
isbinaryfile | ^5.0.0 | Binary file detection |
Exit Codes
| Code | Description |
|---|---|
| 0 | Success |
| 1 | General error (validation failure, file system error, etc.) |
Examples
Basic Usage
- Select “No” for local repository
- Enter:
https://github.com/username/repo - Select desired features (e.g., “Add line numbers”, “Add highlighting”)
- Enter output filename:
my-project.pdf - Select “No” to remove cloned repository
Local Repository
- Select “Yes” for local repository
- Enter path:
/home/user/projects/my-app - Select features
- Enter output filename:
local-project.pdf
Multiple PDFs
- Select repository source
- Select “One PDF per file” in features
- Enter output folder:
./pdfs - Each file will be saved as a separate PDF in the
./pdfsdirectory