A fast, zero-dependency CLI tool for searching and reading the Pali Canon (Tipiṭaka) from the Chaṭṭha Saṅgāyana Tipiṭaka Version 4.0 (CST4).
Built for AI agents and Pali scholars who need quick, precise access to canonical texts — root texts (mūla), commentaries (aṭṭhakathā), and sub-commentaries (ṭīkā).
- Full-text search across the entire Pali Canon with highlighted results
- Read suttas by canonical reference (DN 15, MN 10) or by name (brahmajala, mahanidana)
- Three text layers: mūla (root), aṭṭhakathā (commentary), ṭīkā (sub-commentary)
- Comparative view: see root text alongside its commentary
- Paragraph extraction: pull specific paragraph ranges from any text
- JSON output mode for programmatic use by AI agents and scripts
- Zero dependencies: Python 3.7+ stdlib only — no pip install needed
- Beautiful terminal output with Unicode box-drawing and ANSI colors
Clone one or both CST4 data sources:
# Per-sutta XML (recommended, 44MB, DN/MN/SN/AN)
git clone https://github.com/dhamma/cstxml.git
# Full canon XML (4.9GB, includes Vinaya, Khuddaka, Abhidhamma)
git clone https://github.com/VipassanaTech/tipitaka-xml.git# Place the script alongside the data directories, or specify --data-dir
python3 tipitaka_search.py --data-dir ./cstxml search "paṭiccasamuppāda"Or make it a permanent command:
# Add to your PATH
chmod +x tipitaka_search.py
ln -s $(pwd)/tipitaka_search.py /usr/local/bin/tipitaka
# Now use it anywhere
tipitaka search "paṭiccasamuppāda"Search for Pali terms across the canon:
# Basic search
tipitaka search "paṭiccasamuppāda"
# Filter by nikāya
tipitaka search "cattāri ariyasaccāni" --nikaya SN
# Search in commentaries
tipitaka search "atthasālinī" --layer att
# More context lines
tipitaka search "bojjhaṅga" --context 5
# JSON output (for AI agents / scripts)
tipitaka search "nibbāna" --json --max-results 10Read a full sutta by reference or name:
# By canonical reference
tipitaka read DN.15
tipitaka read MN.10
tipitaka read SN.22
tipitaka read AN.5
# By sutta name (partial match)
tipitaka read brahmajala
tipitaka read mahanidana
tipitaka read mahasatipatthana
# Read the commentary
tipitaka read DN.15 --layer att
# JSON output
tipitaka read MN.10 --jsonBrowse available texts:
# List everything
tipitaka list
# Filter by nikāya
tipitaka list --nikaya MN
tipitaka list --nikaya DNShow metadata about a text:
tipitaka info DN.15
tipitaka info MN.10Output shows nikāya, file ID, Pāli name, word count, and whether commentary/sub-commentary are available.
View root text alongside its commentary:
tipitaka compare DN.15
tipitaka compare MN.10 --max-lines 80Extract specific paragraph ranges:
# Paragraphs 96-110 of DN 15
tipitaka passage DN.15 --start 96 --end 110
# From paragraph 1 onwards
tipitaka passage MN.10 --start 1 --end 20The tool accepts flexible reference formats:
| Format | Example | Meaning |
|---|---|---|
NK N |
DN 15 |
Nikāya + number |
NK.N |
MN.10 |
Dot-separated |
nkN |
sn22 |
Lowercase, no separator |
NK-N |
AN-5 |
Hyphen-separated |
name |
brahmajala |
Sutta name (partial match) |
| Code | Nikāya | Texts |
|---|---|---|
| DN | Dīgha Nikāya | 34 suttas |
| MN | Majjhima Nikāya | 152 suttas |
| SN | Saṃyutta Nikāya | 56 saṃyuttas |
| AN | Aṅguttara Nikāya | 11 nipātas |
| Layer | Name | Description |
|---|---|---|
mul |
Mūla | Root canonical text (default) |
att |
Aṭṭhakathā | Traditional commentary |
tik |
Ṭīkā | Sub-commentary |
All commands support --json for structured output, making the tool ideal for AI agents:
# Search returns structured results
tipitaka search "dukkha" --json | python3 -c "
import json, sys
data = json.load(sys.stdin)
print(f'Found {data[\"total\"]} results')
for r in data['results'][:3]:
print(f' {r[\"ref\"]}: {r[\"line\"][:80]}...')
"This tool works with two CST4 data repositories:
dhamma/cstxml (recommended)
- Per-sutta XML files in romanized Pali (UTF-8)
- Covers DN, MN, SN, AN with mūla, aṭṭhakathā, and ṭīkā
- ~44 MB, ~760 XML files
- Includes typo corrections and clean XML structure
- Full Tipiṭaka in multiple scripts (Romanized, Devanagari, Thai, Myanmar, etc.)
- Includes Vinaya, Khuddaka Nikāya, and Abhidhamma
- ~4.9 GB total, romanized files in
romn/directory
The tool auto-detects available data and uses cstxml for per-sutta access when available, falling back to tipitaka-xml/romn for texts not covered by cstxml.
tipitaka_search.py Single-file CLI (zero dependencies)
├── Index builder Scans XML files, builds name→file mapping
├── XML parser Strips markup, preserves structure
├── Search engine Full-text search with context
├── Ref resolver Parses DN.15, brahmajala, etc.
└── Formatters Terminal (ANSI) and JSON output
The index is cached as .tipitaka-index.json for fast subsequent lookups. Rebuild with tipitaka index --rebuild.
The Chaṭṭha Saṅgāyana Tipiṭaka Version 4.0 is the digital edition of the Pali Canon published by the Vipassana Research Institute. It is based on the Sixth Buddhist Council (Chaṭṭha Saṅgāyana) edition and includes variant readings from multiple editions (Burmese, Sri Lankan, Thai, PTS).
MIT