A transliteration library for Indian Brahmic scripts
npm install lipilekhika> A powerful, typesafe transliteration library for Indian Brahmic scripts with real-time typing support




š Documentation ⢠š Website ⢠š Changelog
- š Bidirectional Transliteration ā Convert between 15+ Indian Brahmic scripts
- š”ļø Full TypeScript Support ā Type-safe script/language names and options
- š¦ Multiple Module Formats ā Tree-shakable ESM, CommonJS, and UMD builds
- ā” Real-time Typing ā Low-latency typing engine for browser environments
- š WASM Support - Use Blazing fast Rust š¦ in JS environments
- šÆ Highly Customizable ā Fine-tune transliteration with custom options
- š Universal Runtime ā Works in Node.js, browsers, Deno, Bun, and more
- šŖ¶ Lightweight ā Only 7 KB gzipped
``bash`
npm install lipilekhika
Other package managers
`bash`
pnpm add lipilekhika
bun add lipilekhika
yarn add lipilekhika
`typescript
import { transliterate } from 'lipilekhika';
// Transliterate from Normal script to Devanagari
const result = await transliterate('na jAyatE mriyatE vA', 'Normal', 'Devanagari');
console.log(result); // न ą¤ą¤¾ą¤Æą¤¤ą„ ą¤®ą„ą¤°ą¤æą¤Æą¤¤ą„ वा
`
`typescript
import { transliterate } from 'lipilekhika';
const result = await transliterate(
'ą°ą°ą°ą°¾',
'Devanagari',
'Gujarati',
{ 'brahmic_to_brahmic:replace_pancham_varga_varna_with_anusvAra': true }
);
console.log(result); // ąŖąŖąŖąŖ¾ (instead of ąŖąŖą«ąŖąŖ¾)
`
š See all Custom Transliteration Options
transliterate(text, from, to, options?) ā Transliterate text between scripts
Parameters:
- text: string ā Text to transliteratefrom: ScriptLangType
- ā Source script/languageto: ScriptLangType
- ā Target script/languageoptions?: TransliterationOptions
- ā Custom transliteration options
Returns: Promise
preloadScriptData(name) ā Preload script data to avoid fetch latency
Parameters:
- name: ScriptLangType ā Script/language name to preload
Returns: Promise
Note: Useful in browsers to avoid initial loading delay.
getAllOptions(from, to) ā Get available custom options for a script pair
Parameters:
- from: ScriptLangType ā Source script/languageto: ScriptLangType
- ā Target script/language
Returns: Promise
transliterate_wasm(text, from, to, options?) ā WASM-based transliteration using Rust
Read more about WASM Module
Parameters:
- text: string ā Text to transliteratefrom: ScriptLangType
- ā Source script/languageto: ScriptLangType
- ā Target script/languageoptions?: TransliterationOptions
- ā Custom transliteration options
Returns: Promise
Note: Uses the fast Rust-based WASM implementation for improved performance. Works in all JavaScript environments (Node.js, browsers, Deno, Bun).
preloadWasm() ā Preload the WASM module
Returns: Promise
Note: Preloads the WASM module to avoid initial loading delay when using transliterate_wasm.
`typescript`
import { SCRIPT_LIST, LANG_LIST, ALL_LANG_SCRIPT_LIST } from 'lipilekhika';
import type { ScriptLangType, TransliterationOptions } from 'lipilekhika';
| Export | Description |
|--------|-------------|
| SCRIPT_LIST | Array of all supported script names |LANG_LIST
| | Array of all supported language names mapped to scripts |ALL_LANG_SCRIPT_LIST
| | Combined list of all scripts and languages |ScriptLangType
| | Type for script/language identifiers (includes aliases) |TransliterationOptions
| | Type for custom transliteration options |ScriptListType
| | Type for the script list |LangListType
| | Type for the language list |
Enable real-time transliteration as users type in
`typescript`
import {
createTypingContext,
handleTypingBeforeInputEvent,
clearTypingContextOnKeyDown
} from 'lipilekhika/typing';
š Browser Typing Tool Guide ⢠API Reference
`tsx
import { createTypingContext, handleTypingBeforeInputEvent, clearTypingContextOnKeyDown } from 'lipilekhika/typing';
const ctx = createTypingContext('Telugu');
onBeforeInput={(e) => handleTypingBeforeInputEvent(ctx, e, setText)}
onBlur={() => ctx.clearContext()}
onKeyDown={(e) => clearTypingContextOnKeyDown(e, ctx)}
/>
`
createTypingContext(script, options?) ā Create a typing context
Parameters:
- script: ScriptLangType ā Target script/language for typingoptions?: TypingOptions
- ā Custom typing optionsautoContextClearTimeMs?: number
- (default: 4500)useNativeNumerals?: boolean
- (default: true)includeInherentVowel?: boolean
- (default: false)
Returns: TypingContext with:ready: Promise
- ā Await before using (ensures script data loaded)takeKeyInput(char: string)
- ā Process character input and return diffclearContext()
- ā Clear internal stateupdateUseNativeNumerals(value: boolean)
- ā Update numeral preferenceupdateIncludeInherentVowel(value: boolean)
- ā Update inherent vowel inclusion
handleTypingBeforeInputEvent(ctx, event, callback?, options?) ā Handle beforeinput events
Parameters:
- ctx: TypingContext ā Typing contextevent: InputEvent
- ā The beforeinput eventcallback?: (newValue: string) => void
- ā Called with updated valueoptions?
- ā Additional options
clearTypingContextOnKeyDown(event, ctx) ā Handle keyboard events
Handles keyboard events (Arrow keys, Esc, etc.) to clear context appropriately.
Parameters:
- event: KeyboardEvent ā The keydown eventctx: TypingContext
- ā Typing context to clear
`typescript
import { getScriptKramaData, getScriptTypingDataMap } from 'lipilekhika/typing';
// Get sequential character array (krama) for a script
const kramaData = await getScriptKramaData('Devanagari');
// Returns: [['ą¤
', 'svara'], ['ą¤', 'svara'], ['ą¤', 'vyanjana'], ...]
// Get detailed typing mappings for a script
const typingMap = await getScriptTypingDataMap('Telugu');
// Useful for building typing helper UIs
`
ESM (Module)
`html`
UMD (Global)
`html``
---
- Documentation Home ā Complete guides and API reference
- JavaScript Guide ā Getting started with JS/TS
- Browser Typing Tool ā Real-time typing integration
- Supported Scripts ā Full list of scripts
- Custom Options ā Transliteration options reference
- GitHub Repository ā Source code and issues
- Changelog ā Version history and updates