Usage Guide

Type Roman letters (English) to get Nepali Unicode text. The converter works in real-time as you type.

Examples:

Special Character Keys:

Case-Sensitive Characters:

Special Conjuncts (Combined Consonants):

Tips for Accurate Conversion:

// Fix "reph" form (र + ्) at the beginning of a conjunct text = text.replace(/([क-ह])र्/g, 'र्$1'); // Handle anusvara (ं) positioning text = text.replace(/([ािीुूृेैोौ])ं/g, '$1ँ'); // Handle chandrabindu (ँ) properly text = text.replace(/([क-ह])ँ/g, '$1ँ'); // Fix common incorrect forms text = text.replace(/क्स/g, 'क्ष'); text = text.replace(/त्र्/g, 'त्र'); text = text.replace(/ज्ञ्/g, 'ज्ञ'); // Fix half letters with a vowel sign text = text.replace(/([क-ह])्([ािीुूृेैोौ])/g, '$1$2'); // Handle visarga (:) character text = text.replace(/:([क-ह])/g, 'ः$1'); // Apply typical Nepali diacritic rules text = text.replace(/([क-ह])([ि])/g, '$2$1'); // i-kar (ि) goes before consonant text = text.replace(/([क-ह])([ीुूृेैोौ])/g, '$1$2'); // other vowel signs go after // Handle "au" and "ai" diphthongs text = text.replace(/([क-ह])ाै/g, '$1ौ'); text = text.replace(/([क-ह])ाे/g, '$1ो'); text = text.replace(/([क-ह])ाै/g, '$1ौ'); text = text.replace(/([क-ह])ाई/g, '$1ै'); // Fix common word endings text = text.replace(/को/g, 'को'); text = text.replace(/मा/g, 'मा'); text = text.replace(/ले/g, 'ले'); text = text.replace(/बाट/g, 'बाट'); return text; }; // Utility function to escape special characters in regex const escapeRegex = (string) => { return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); }; // Process replacement in proper order with longest matches first const processReplacements = (text, dictionary) => { // Sort keys by length (longest first) to avoid partial replacements const sortedKeys = Object.keys(dictionary).sort((a, b) => b.length - a.length); for (const key of sortedKeys) { const escapedKey = escapeRegex(key); const regex = new RegExp(escapedKey, 'g'); text = text.replace(regex, dictionary[key]); } return text; }; // First check for common words (direct conversions) let convertedText = processReplacements(plainText, commonWords); // Then apply custom rules for consonant+vowel combinations convertedText = processReplacements(convertedText, customRules); // Then apply conjuncts convertedText = processReplacements(convertedText, conjuncts); // Then apply half letters convertedText = processReplacements(convertedText, halfLetters); // Then apply consonants convertedText = processReplacements(convertedText, consonants); // Then apply vowels convertedText = processReplacements(convertedText, vowels); // Then apply numbers convertedText = processReplacements(convertedText, numbers); // Finally apply special characters convertedText = processReplacements(convertedText, special); // Handle specific Nepali grammar rules convertedText = refineGrammar(convertedText); // Specific fixes for consonant-vowel combinations convertedText = convertedText.replace(/([क-ह])्अ/g, '$1'); // Remove halant+अ combination convertedText = convertedText.replace(/([क-ह])्आ/g, '$1ा'); // Fix halant+आ → vowel sign ा convertedText = convertedText.replace(/([क-ह])्इ/g, '$1ि'); // Fix halant+इ → vowel sign ि convertedText = convertedText.replace(/([क-ह])्ई/g, '$1ी'); // Fix halant+ई → vowel sign ी convertedText = convertedText.replace(/([क-ह])्उ/g, '$1ु'); // Fix halant+उ → vowel sign ु convertedText = convertedText.replace(/([क-ह])्ऊ/g, '$1ू'); // Fix halant+ऊ → vowel sign ू convertedText = convertedText.replace(/([क-ह])्ए/g, '$1े'); // Fix halant+ए → vowel sign े convertedText = convertedText.replace(/([क-ह])्ऐ/g, '$1ै'); // Fix halant+ऐ → vowel sign ै convertedText = convertedText.replace(/([क-ह])्ओ/g, '$1ो'); // Fix halant+ओ → vowel sign ो convertedText = convertedText.replace(/([क-ह])्औ/g, '$1ौ'); // Fix halant+औ → vowel sign ौ // Apply final spacing and word spacing fixes // Fix spaces between Nepali words convertedText = convertedText.replace(/([क-ह])(\s+)([क-ह])/g, '$1 $3'); // Fix post-conversion spacing around punctuation convertedText = convertedText.replace(/(\s+)(।)/g, '$2'); convertedText = convertedText.replace(/(।)(\s+)/g, '$1 '); // Process each word to ensure internal consistency const words = convertedText.split(/\s+/); convertedText = words.map(word => { // Fix incorrect half letters at the end of words if (/[क-ह]्$/.test(word)) { return word.replace(/([क-ह])्$/, '$1'); } return word; }).join(' '); // Replace placeholders for English text convertedText = convertedText.replace(/§§(\d+)§§/g, (match, p1) => engParts[parseInt(p1)]); // Log final output for debugging console.log('Final Converted Text:', convertedText); return convertedText; } });