Nutella with Pepperoni and Mushrooms
Meet npm Pro: unlimited public & private packages + package-based permissions.Learn more »


2.2.0 • Public • Published


General utilities for working with Gurmukhi text data.

CircleCI Coveralls github npm license Try on RunKit

Want to speak with us?




The library can be imported into Node as below:

const { toUnicode, toAscii, firstLetters, transliterate, toShahmukhi } = require('gurmukhi-utils')
toUnicode('Koj')    // => ਖੋਜ
toAscii('ਖੋਜ')      // => Koj
firstLetters('hir hir hir gunI')  // => hhhg
firstLetters('ਹਰਿ ਹਰਿ ਹਰਿ ਗੁਨੀ')   // => ਹਹਹਗ
transliterate('hukmI hukmu clwey rwhu ]')  // => hukamee hukam chalaae raahu ||
toHindi('ਕੁਲ ਜਨ ਮਧੇ ਮਿਲੵੋਿ ਸਾਰਗ ਪਾਨ ਰੇ ॥')    // => कुल जन मधे मिल्यो सारग पान रे ॥
toShahmukhi('ਹਰਿ ਹਰਿ ਹਰਿ ਗੁਨੀ') // => هر هر هر گُنی

Additionally, the package is available for web use via unpkg CDN.

<script src=""></script>

Want to play around? Try gurmukhi-utils on RunKit


firstLetters(line, [stripNukta], [withVishraams]) ⇒ String

Generates the first letters for a given ASCII or unicode Gurmukhi string. By default, the function will transform letters with bindi to their simple equivalent, for example, zaza to jaja (ਜ਼ => ਜ).

Returns: String - The first letters of each word in the provided Gurmukhi line.

Param Type Default Description
line String The line to generate the first letters for.
[stripNukta] Boolean true If true, replaces letters pair bindi (such as ਜ਼) with their equivalent without the bindi (ਜ). Also replaces open oora with closed oora.
[withVishraams] Boolean false Keeps the vishraam characters at the end of each word.

Example (Unicode first letters no pair bindi/nukta)

firstLetters('ਗ਼ੈਰਿ ਹਮਦਿ ਹੱਕ ਨਿਆਇਦ ਬਰ ਜ਼ਬਾਨਮ ਹੀਚ ਗਾਹ') // => ਗਹਹਨਬਜਹਗ

Example (Unicode first letters with pair bindi/nukta)

firstLetters('ਗ਼ੈਰਿ ਹਮਦਿ ਹੱਕ ਨਿਆਇਦ ਬਰ ਜ਼ਬਾਨਮ ਹੀਚ ਗਾਹ', false) // => ਗ਼ਹਹਨਬਜ਼ਹਗ

Example (Unicode first letters with vishraams)

firstLetters('ਸਬਦਿ ਮਰੈ. ਸੋ ਮਰਿ ਰਹੈ; ਫਿਰਿ. ਮਰੈ ਨ, ਦੂਜੀ ਵਾਰ ॥', true, true) // => ਸਮ.ਸਮਰ;ਫ.ਮਨ,ਦਵ

Example (ASCII first letters no pair bindi/nukta)

firstLetters('ijs no ik®pw krih iqin nwmu rqnu pwieAw ]') // => jnkkqnrp
firstLetters('iZir&qym sMdUk drIXw AmIk ]') // => gsdA

Example (ASCII first letters with pair bindi/nukta)

firstLetters('iZir&qym sMdUk* drIXw AmIk* ]', false) // => Zsda

Example (ASCII first letters with vishraams)

firstLetters('sbid mrY. so mir rhY; iPir. mrY n, dUjI vwr ]', true, true) // => sm.smr;,dv

toAscii(text) ⇒ String

Converts Gurmukhi unicode text to ASCII, used GurmukhiAkhar font.

Returns: String - An ASCII representation of the provided unicode Gurmukhi string.

Param Type Description
text String The unicode text to convert.


toAscii('ਹਮਾ ਸਾਇਲਿ ਲੁਤਫ਼ਿ ਹਕ ਪਰਵਰਸ਼ ॥') // => hmw swieil luqi& hk prvrS ]
toAscii('ਸੁ ਬੈਠਿ ਇਕੰਤ੍ਰ ॥੫੭੮॥') // => su bYiT iekMqR ]578]

toEnglish(line) ⇒ String

Transliterates a line from Unicode Gurmukhi to english. Currently supports the ,, ;, . vishraam characters.

Returns: String - The English transliteration of the provided Gurmukhi line.

Param Type Description
line String The Gurmukhi Unicode line to transliterate.


toEnglish('ਹੁਕਮੀ ਹੁਕਮੁ ਚਲਾਏ ਰਾਹੁ ॥') // => hukamee hukam chalaae raahu ||


toEnglish('ਭਾਂਡਾ ਭਾਉ ਅੰਮ੍ਰਿਤੁ ਤਿਤੁ ਢਾਲਿ ॥') // => bhaa(n)ddaa bhaou anmrit tit dtaal ||

toHindi(text) ⇒ String

Transliterates Unicode Gurmukhi text to Hindi (Devanagari script).

Returns: String - A Hindi transliteration of the provided Unicode Gurmukhi string.

Param Type Description
text String The Unicode Gurmukhi text to convert.


toHindi('ਕੁਲ ਜਨ ਮਧੇ ਮਿਲੵੋਿ ਸਾਰਗ ਪਾਨ ਰੇ ॥') // => कुल जन मधे मिल्यो सारग पान रे ॥
toHindi('ਸੁ ਬੈਠਿ ਇਕੰਤ੍ਰ ॥੫੭੮॥') // => सु बैठ इकंत्र ॥५७८॥

toShahmukhi(text) ⇒ String

Transliterates Unicode Gurmukhi text to the Shahmukhi script.

Returns: String - A Shahmukhi transliteration of the provided Unicode Gurmukhi string.

Param Type Description
text String The Unicode Gurmukhi text to convert.


toShahmukhi('ਹਮਾ ਸਾਇਲਿ ਲੁਤਫ਼ਿ ਹਕ ਪਰਵਰਸ਼ ॥') // => هما ساِال لُتف هک پرورش ۔۔
toShahmukhi('ਸੁ ਬੈਠਿ ਇਕੰਤ੍ਰ ॥੫੭੮॥') // => سُ بَےٹھ ِاکںتر ۔۔۵۷۸۔۔

toUnicode(text) ⇒ String

Converts ASCII text used in the GurmukhiAkhar font to Unicode.

Returns: String - A unicode representation of the provided ASCII Gurmukhi string.

Param Type Description
text String The ASCII text to convert.


toUnicode('kul jn mDy imil´o swrg pwn ry ]') // => ਕੁਲ ਜਨ ਮਧੇ ਮਿਲੵੋਿ ਸਾਰਗ ਪਾਨ ਰੇ ॥
toUnicode('su bYiT iekMqR ]578]') // => ਸੁ ਬੈਠਿ ਇਕੰਤ੍ਰ ॥੫੭੮॥


We're happy to accept suggestions and pull requests!

To get started, clone this repo and run npm install inside this directory.

This repository follows the Airbnb's Javascript Style Guide, with a few minor modifications. Notably, spaces should be included inside parentheses and brackets (weird, right!). An ESLint file is provided, and your code will automatically be checked on-commit for style. It is recommended to install an ESLint plugin for your editor (VS Code's ESLint plugin works out of the box), so you can receive linter suggestions as you type.

When writing commit messages, please follow the seven rules. Markdown and HTML JSDoc documentation is generated automatically, on commit, however if you'd like to preview any changes to documentation, npm run build-docs will update and the files in docs/. should not be edited, instead apply modifications to README.hbs.

The general workflow for contributing:

  • Fork/create a new branch.
  • Write or update existing tests with expected results
  • Implement functions/changes
  • Add JSDoc function documentation and examples.
  • Run tests with npm test and ensure they all pass. Testing is done with the mocha testing framework.
  • Create a pull request with the changes.

Note to contributors with push access to master: Any commits or merge commits containing the strings #Major, #Minor, #Patch (case-sensitive) will trigger an automatic npm release with the respective semver bump.


npm i gurmukhi-utils

DownloadsWeekly Downloads






Unpacked Size

164 kB

Total Files


Last publish


  • avatar