Txtar Viewer
A powerful VS Code extension for viewing and creating txtar format text archive files.

What is Txtar?
Txtar is a simple text archive format originally created by the Go team for storing multiple files in a single text file. It's perfect for:
- 📝 Code examples and test cases
- 📦 Project templates and scaffolding
- 🔄 Batch file sharing
- 📚 Multi-file examples in documentation
Try it online: https://txtar.dev
Features
1. Export Directory/Files to Txtar
Right-click on folders or files to export them as txtar archives:
- Git Mode (default): Automatically detects Git repositories and exports only tracked files
- Auto-fallback: Automatically switches to normal mode when not in a Git repository
- Multi-select Support: Select multiple files and folders simultaneously
- Smart Filtering: Automatically ignores binary files (images, videos, archives, etc.)
How to use:
- Right-click on file/folder → "Copy as Txtar" - Copy to clipboard
- Right-click on file/folder → "Export as Txtar File" - Save as .txtar file
2. Txtar File Viewer
When opening .txtar files, automatically displays:
- 📁 Directory Tree View: Clear file structure navigation
- 🎨 Syntax Highlighting: Support for 50+ programming languages
- 🔍 File Preview: Click on files to view content
- 📝 Comment Support: Display archive description
Installation
Method 1: VS Code Marketplace (Recommended)
- Open VS Code
- Press
Ctrl+Shift+X (macOS: Cmd+Shift+X) to open Extensions
- Search for "Txtar Viewer"
- Click "Install"
Method 2: Command Line
code --install-extension phlv.vscode-txtar
Method 3: Marketplace Page
Visit VS Code Marketplace to install directly
Usage
Creating Txtar Archives
- In VS Code's file explorer, right-click on files or folders
- Choose one of the following actions:
- Copy as Txtar - Copy content to clipboard for sharing
- Export as Txtar File - Save as a
.txtar file
Multi-select Example:
- Hold
Ctrl (macOS: Cmd) and click multiple files
- Right-click → "Copy as Txtar"
- All selected files will be packaged into one txtar archive
Viewing Txtar Files
- Open any
.txtar file in VS Code
- Automatically displays file tree and preview interface
- Click on filenames in the left tree to view content
- Enjoy syntax highlighting for comfortable reading
Supported Languages
The extension automatically detects file types and applies syntax highlighting for:
- Web: JavaScript, TypeScript, HTML, CSS, SCSS, Vue, React
- Backend: Python, Go, Rust, Java, C/C++, C#, PHP, Ruby
- Config: JSON, YAML, TOML, XML, INI
- Shell: Bash, PowerShell, Batch
- Data: SQL, GraphQL, Markdown
- And more: 50+ programming languages
How It Works
Git Mode (Default)
In Git repositories, the extension will:
- Automatically detect Git repository
- Export only tracked files (respecting
.gitignore)
- Keep clean output, excluding
node_modules, .git, etc.
Auto-fallback
When not in a Git repository:
- Automatically switches to normal mode
- Recursively scans directory
- Intelligently filters binary files
Binary File Filtering
By default, ignores the following file types:
- Images:
.png, .jpg, .gif, .ico, .svg
- Videos:
.mp4, .avi, .mov
- Audio:
.mp3, .wav, .ogg
- Archives:
.zip, .tar, .gz, .7z
- Executables:
.exe, .dll, .so, .dylib
- Other binary formats
Basic txtar file format:
This is the comment area where you can describe the archive content.
Comments are separated from files by a blank line.
-- file1.txt --
Content of file 1
Can have multiple lines
-- dir/file2.js --
console.log('Hello, Txtar!');
-- dir/file3.py --
print("Supports any text file")
Format Rules:
- File separator:
-- filename --
- Supports directory paths:
-- path/to/file.txt --
- Text at the beginning serves as comments
- Pure text format, easy for version control
Links
Tech Stack
- TypeScript
- VS Code Extension API
- Custom Editor API
- Highlight.js (Syntax highlighting)
- simple-git (Git integration)
License
MIT License
Feedback
If you find this extension useful, please leave a ⭐ rating on the marketplace!
Enjoy using Txtar Viewer!
| |