A beautiful, interactive web application to visualize and explore the complete directory structure of any public or private GitHub repository.
Live Demo โข Features โข Getting Started โข Usage โข Tech Stack
- ๐ Instant Visualization - Fetch and display complete repository structures in seconds
- ๐ Private Repository Support - Access private repos with Personal Access Token (PAT)
- ๐ฒ Tree View - Beautiful, hierarchical tree representation with folder/file icons
- ๐ One-Click Copy - Copy individual file paths or the entire tree structure
- ๐ฏ Branch Support - Explore any branch of a repository
- ๐ฑ Responsive Design - Works seamlessly on desktop, tablet, and mobile devices
- โก Fast & Lightweight - Built with modern React and Vite for optimal performance
- ๐จ Clean UI - Modern, intuitive interface with smooth animations
- ๐ Secure - PAT stored only in browser memory, never sent to third-party servers
- ๐ Rate Limit Friendly - Support for authenticated requests (5,000/hour vs 60/hour)
- Node.js (v18 or higher)
- npm, yarn, or pnpm
-
Clone the repository
git clone https://github.com/yourusername/github-tree-viewer.git cd github-tree-viewer -
Install dependencies
npm install # or yarn install # or pnpm install
-
Start the development server
npm run dev # or yarn dev # or pnpm dev
-
Open your browser
Navigate to
http://localhost:5173to see the application running.
npm run build
npm run preview-
Enter Repository Details
- Input the repository in the format:
username/repository - Example:
facebook/reactormicrosoft/vscode
- Input the repository in the format:
-
Specify Branch (Optional)
- Enter the branch name (defaults to
main) - Common branches:
main,master,develop,staging
- Enter the branch name (defaults to
-
Fetch Structure
- Click the "Fetch" button or press Enter
- Wait for the tree structure to load
-
Interact with the Tree
- Browse the complete directory structure
- Hover over items to reveal the copy button
- Click to copy individual file paths
- Use "Copy Tree" to copy the entire structure
To access private repositories, you need to provide a GitHub Personal Access Token (PAT):
-
Generate a Personal Access Token
- Go to GitHub Settings โ Developer settings โ Personal access tokens โ Tokens (classic)
- Click "Generate new token (classic)"
- Give it a descriptive name (e.g., "GitHub Tree Viewer")
- Select the
reposcope (this grants access to private repositories) - Set an appropriate expiration date
- Click "Generate token" and copy it immediately
-
Add Token to the App
- Click "Add Personal Access Token (for private repos)" in the app
- Paste your token in the input field
- The app will show "Authenticated" status when a token is present
-
Security Notes
- Your token is stored only in browser memory
- It's never sent to any server except GitHub's API
- The token is not persisted and will be cleared on page refresh
- For security, only grant the minimum necessary permissions
Public Repositories:
facebook/react- React JavaScript librarymicrosoft/vscode- Visual Studio Codevercel/next.js- Next.js frameworktailwindlabs/tailwindcss- Tailwind CSS
Private Repositories:
- Use your own private repos with a PAT
- Access organization private repositories (requires appropriate PAT permissions)
| Technology | Purpose |
|---|---|
| UI framework for building the interface | |
| Type-safe JavaScript development | |
| Fast build tool and dev server | |
| Utility-first CSS framework |
- Lucide React - Beautiful icon library
- GitHub API - Fetching repository tree data
- ESLint - Code linting and quality
- PostCSS - CSS processing
- Autoprefixer - CSS vendor prefixing
github-tree-viewer/
โโโ src/
โ โโโ App.tsx # Main application component
โ โโโ main.tsx # Application entry point
โ โโโ index.css # Global styles
โ โโโ vite-env.d.ts # Vite type definitions
โโโ public/ # Static assets
โโโ index.html # HTML template
โโโ package.json # Project dependencies
โโโ tsconfig.json # TypeScript configuration
โโโ tailwind.config.js # Tailwind CSS configuration
โโโ vite.config.ts # Vite configuration
โโโ README.md # Project documentation
The application uses a sophisticated algorithm to:
- Fetch repository data from GitHub's Git Trees API
- Parse flat file paths into hierarchical structure
- Sort folders before files alphabetically
- Render with proper tree connectors (โโโ, โโโ, โ)
- Optional Authentication: Works without PAT for public repos
- Secure Token Handling: PAT stored only in component state
- Smart Error Messages: Guides users to add PAT when needed
- Privacy Indicator: Shows lock icon for private repositories
- Smart Tree Rendering: Efficient algorithm for building nested structures
- Path Copy: Individual file path copying with visual feedback
- Bulk Export: Copy entire tree structure in ASCII format
- Error Handling: User-friendly error messages for invalid repos
- Loading States: Visual feedback during API calls
- Rate Limit Detection: Informs users when limits are reached
This application uses the GitHub Git Data API:
GET /repos/{owner}/{repo}/git/trees/{tree_sha}?recursive=1
# Without PAT (public repos only)
curl https://api.github.com/repos/facebook/react/git/trees/main?recursive=1
# With PAT (public and private repos)
curl -H "Authorization: Bearer YOUR_PAT" \
https://api.github.com/repos/username/private-repo/git/trees/main?recursive=1| Request Type | Rate Limit |
|---|---|
| Unauthenticated | 60 requests per hour |
| Authenticated (PAT) | 5,000 requests per hour |
Note: The app works without authentication for public repositories but requires a PAT for private repos.
- Client-Side Only: Your PAT is only stored in browser memory
- No Server Storage: Token is never sent to any third-party server
- Direct to GitHub: Tokens are only used in direct API calls to GitHub
- No Persistence: Token is cleared on page refresh
- User Control: Easily toggle visibility and remove tokens
- Use Fine-Grained Tokens: Consider using fine-grained PATs with minimal permissions
- Set Expiration: Always set an expiration date for your tokens
- Revoke When Done: Revoke tokens when you no longer need them
- Don't Share: Never share your PAT or commit it to version control
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Follow the existing code style
- Write meaningful commit messages
- Test your changes thoroughly
- Update documentation as needed
- Ensure security best practices for PAT handling
This project is licensed under the MIT License - see the LICENSE file for details.
- Very large repositories (10,000+ files) may be truncated by GitHub API
- PAT is not persisted across sessions (by design for security)
- Some organization repositories may require additional permissions
- GitHub authentication for private repositories
- Higher rate limits support
- Token persistence with encryption (optional)
- Fine-grained token support with custom permissions
- File size information display
- Search/filter functionality
- Export to different formats (JSON, YAML)
- Dark mode support
- Collapsible folders
- File type statistics
- Multi-repository comparison
- Repository favorites/bookmarks
Click "Add Personal Access Token" in the app and provide a GitHub PAT with the repo scope. See the Private Repository Access section for detailed instructions.
Yes. Your token is only stored in browser memory and is never sent to any server except GitHub's API. It's cleared on page refresh and never persisted.
GitHub's API truncates very large repositories (10,000+ files). If you see a warning, some files may not be displayed. This is a GitHub API limitation.
For basic private repository access, the repo scope is sufficient. For organization repositories, you may need additional permissions.
Yes, both public and private organization repositories are supported with an appropriate PAT.
Project Maintainer: Your Name
- GitHub: @aryan-git-byte
- Email: aryan17550@gmail.com
- GitHub API for providing the data
- Lucide for beautiful icons
- Tailwind CSS for styling utilities
- Vite for blazing fast development experience
- GitHub community for security best practices
โญ Star this repository if you find it helpful!
Made with โค๏ธ by Your Name