How to Transliterate Sanskrit
This guide demonstrates how to use vyasa-lipi—both as a standalone CLI tool and as a Rust library—to perform lossless transliteration of Vedic and Classical Sanskrit texts across 11 supported formats.
1. Installing the CLI
Section titled “1. Installing the CLI”From the root of the vyutils workspace:
# Build release binarycargo build --release -p vyasa-lipi
# Install directly to your PATH (~/.cargo/bin)cargo install --path crates/vyasa-lipiVerify the installation:
vyasa-lipi --version2. Basic Transliteration
Section titled “2. Basic Transliteration”Indic Abugida Conversion
Section titled “Indic Abugida Conversion”Transliterate a verse from the Bhagavad Gita (1.1) from Devanagari to Telugu:
vyasa-lipi --from devanagari --to telugu "धर्मक्षेत्रे कुरुक्षेत्रे समवेता युयुत्सवः"Output:
ధర్మక్షేత్రే కురుక్షేత్రే సమవేతా యుయుత్సవఃTransliterate to Kannada:
vyasa-lipi --from devanagari --to kannada "धर्मक्षेत्रे कुरुक्षेत्रे समवेता युयुत्सवः"Output:
ಧರ್ಮಕ್ಷೇತ್ರೇ ಕುರುಕ್ಷೇತ್ರೇ ಸಮವೇತಾ ಯುಯುತ್ಸವಃ3. Vedic Pitch Accent Preservation
Section titled “3. Vedic Pitch Accent Preservation”By default, vyasa-lipi preserves all Vedic pitch accents (Udātta, Anudātta, Svarita, DīrghaSvarita).
Transliterate Ṛgveda 1.1.1 to Telugu:
vyasa-lipi --from devanagari --to telugu "अ॒ग्निमी॑ळे पु॒रोहि॑तम्"Output:
అ॒గ్నిమీ॑ళే పు॒రోహి॑తమ్Notice:
- The Anudātta under-bar (
\u0952) on a and ro is preserved. - The Svarita vertical stroke (
\u0951) on mī is preserved. - The Vedic flap ळ (
\u0933) is mapped to Telugu ళ (\u0C33).
Stripping Accents for Search Indexing
Section titled “Stripping Accents for Search Indexing”If you are preparing text for non-Vedic readers or generating search indexes where accents interfere with matching, use --accents strip:
vyasa-lipi --from devanagari --to devanagari --accents strip "अ॒ग्निमी॑ळे पु॒रोहि॑तम्"Output:
अग्निमीळे पुरोहितम्4. Transliterating to Grantha & Malayalam
Section titled “4. Transliterating to Grantha & Malayalam”Grantha is the canonical Tamil-region Sanskrit script:
vyasa-lipi --from devanagari --to grantha "धर्मक्षेत्रे कुरुक्षेत्रे"Output:
𑌧𑌰𑍍𑌮𑌕𑍍𑌷𑍇𑌤𑍍𑌰𑍇 𑌕𑍁𑌰𑍁𑌕𑍍𑌷𑍇𑌤𑍍𑌰𑍇Malayalam:
vyasa-lipi --from devanagari --to malayalam "धर्मक्षेत्रे कुरुक्षेत्रे"Output:
ധര്മക്ഷേത്രേ കുരുക്ഷേത്രേ5. Automatic Script Detection
Section titled “5. Automatic Script Detection”If you omit the --from flag, vyasa-lipi automatically inspects the Unicode codepoints of the input:
# Detected as Telugu -> Transliterated to Devanagarivyasa-lipi --to devanagari "ధర్మక్షేత్రే కురుక్షేత్రే"Output:
धर्मक्षेत्रे कुरुक्षेत्रे# Detected as Kannada -> Transliterated to IASTvyasa-lipi --to iast "ಧರ್ಮಕ್ಷೇತ್ರೇ ಕುರುಕ್ಷೇತ್ರೇ"Output:
dharmakṣētrē kurukṣētrē6. Strict ISO 15919 vs Academic IAST
Section titled “6. Strict ISO 15919 vs Academic IAST”Depending on whether you need strict international library standards or standard Indological transcription:
# ISO 15919 (under-ring for r̥, macron for ē)vyasa-lipi --to iso15919 "कृष्णः"# kr̥ṣṇaḥ
# Standard IAST (under-dot for ṛ)vyasa-lipi --to iast "कृष्णः"# kṛṣṇaḥ7. Computational ASCII Formats (SLP1, HK, WX)
Section titled “7. Computational ASCII Formats (SLP1, HK, WX)”When feeding Sanskrit into computational pipelines, parsers, or search engines:
# Convert Devanagari to SLP1 (Cologne Sanskrit dictionary standard)vyasa-lipi --from devanagari --to slp1 "धर्मक्षेत्रे कुरुक्षेत्रे"# Darmakzetre kurukzetre
# Convert back from SLP1 to Devanagarivyasa-lipi --from slp1 --to devanagari "Darmakzetre kurukzetre"# धर्मक्षेत्रे कुरुक्षेत्रे8. Piped Input & Batch Processing
Section titled “8. Piped Input & Batch Processing”vyasa-lipi accepts input from standard input (stdin), making it ideal for shell scripts and corpus pipelines:
# Process a full chapter from filecat gita_chapter1_deva.txt | vyasa-lipi --to telugu > gita_chapter1_telu.txt
# Inspect difference after round-tripdiff <(cat text.txt) <(cat text.txt | vyasa-lipi --to telugu | vyasa-lipi --to devanagari)# Zero output confirms byte-identical round-trip fidelity!9. Rust API Integration
Section titled “9. Rust API Integration”Add vyasa-lipi to your project’s Cargo.toml:
[dependencies]vyasa-lipi = { path = "../crates/vyasa-lipi" }Example Rust Program
Section titled “Example Rust Program”use vyasa_lipi::{detect_script, transliterate, Script};use vyasa_lipi::model::AccentMode;
fn main() { let input = "अ॒ग्निमी॑ळे पु॒रोहि॑तम्";
// Auto-detect source script let src = detect_script(input).unwrap_or(Script::Devanagari);
// Transliterate to Telugu with accents preserved let telugu = transliterate(input, src, Script::Telugu, AccentMode::Preserve); println!("Telugu: {}", telugu);
// Transliterate to IAST with accents stripped let iast = transliterate(input, src, Script::Iast, AccentMode::Strip); println!("IAST (stripped): {}", iast);
// Verify round-trip back to Devanagari let roundtrip = transliterate(&telugu, Script::Telugu, Script::Devanagari, AccentMode::Preserve); assert_eq!(roundtrip, input);}Next Steps
Section titled “Next Steps”- Consult the complete flag and script reference: vyasa-lipi Reference
- Learn about the underlying phonetic models: Sanskrit Phonetics