Its usage is similar, but not identical, to another subcontinental honorific, sāhab. Similar to the Japanese honorific -san, ji is gender-neutral and can be used for as a term of respect for inanimate objects as well.
The origin of the ji honorific is uncertain. One suggestion is that it is a borrowing from an Austroasiatic language such as Sora. Another is that the term means 'soul' or 'life' (similar to the jān suffix) and is derived from Sanskrit.
Sāhab (or sāhib) is always used for an individual, never for an inanimate object or group, though the plural term Sāheban exists as well for more than one person. "Sāhab" is also never used as a shorthand to express agreement, disagreement or ask clarification (whereas "ji" is, such as in Ji, Ji nahi or Ji?). Sometimes, the two terms can be combined to Sāhab Ji to indicate a high degree of respect, roughly equivalent to Respected Sir.
Jān is also a commonly used suffix in the subcontinent, but it (and the variant, Jānī) denotes endearment rather than respect and, in some contexts, can denote intimacy or even a romantic relationship. Due to these connotations of intimacy, the subcontinental etiquette surrounding Jān is more complex than the usage of the same term in Persian, where it is used somewhat more liberally (though even there, restrictions apply).
As a standalone term, Jān is the rough equivalent of Darling, and is used almost exclusively for close relatives (such as spouses, lovers and children). In this context, sometimes colloquial forms such as Jānoo and Jānaa, or combination words such as Jāneman (my darling) and Jānejaan/Jānejaana (roughly, love of my life), are also used. When used with a name or a relation-term, it means dear. So, bhāi-sāhab and bhāi-ji carry the meaning of respected brother, whereas bhāi-jān or bhaiyya-jānī mean dear brother. The term meri jān, roughly meaning my dear, can be used with friends of the same gender, or in intimate relationships with the opposite gender. In subcontinental etiquette, while bhaijan can be used by males to denote a brotherly relation with any other male of a roughly similar age including total strangers (the female equivalent between women is apajan or didijan), meri jān is used only with friends with whom informality has been established. Ji, on the other hand, is appropriate in all these situations and across genders because it carries no connotations of intimacy.
Popular conflation with the letter 'G'
Because English usage is widespread in the Indian subcontinent, the fact that the honorific Ji is pronounced identically to the letter G is used extensively in puns. This is sometimes deliberately exploited in consumer marketing, such as with the popular "Parle-G Biscuits" (where the 'G' ostensibly stands for Glucose), which sounds like Parle Ji Biscuits (or, the respected Parle biscuits). A pun popular with children in North India and Pakistan consists entirely of English letters - BBG T PO G, which is pronounced very similarly to Bibi-ji, Tea pi-o ji (meaning, respected ma'am, please have some tea). Some people also add an 'A' or 'O' to this pun as a prefix to give effect as if a person is calling the Bibi-ji, in a typical Indian friendly way used in regional slangs. Thus we may also write it as O BBG T PO G. One may even add the answer of Bibi-ji as PKIG, means I just had the tea.
It has been known for a Hindi name ending in -ji to be rendered in Sanskrit as -opadhyay (i.e. -a-upādhyāya with sandhi). "upādhyāya" is Sanskrit for "teacher".
^R. Caldwell Smith, S. C. R. Weightman (1994), Introductory Hindi course, North India Institute of Language Study Society, "... How is the honorific 'ji' used ? It is added after the identification of a person ..."
^Herbert Feldman (1968), Pakistan: an introduction, Oxford University Press, "... to use the word 'ji' which, by itself, means 'yes' or, when used as suffix to a name as for example in Rustomji, is a way of speaking to that person, or of referring to him, with respect ..."
^Archiv Orientální, Volume 75, Československý orientální ústav v Praze, Orientální ústav (Československá akademie věd), 2007, ... Artur Karp is concerned with the etymology of the honorific —ji, which belongs to the basic vocabulary of Hindi. Its etymology is unclear and the author points out several possibilities ...
^Sora-English Dictionary, Giḍugu Veṅkaṭarāmamūrti, Mittal Publications, 1986, ... Is honorific -ji used in the neo-Aryan languages of India borrowed from Sora? ...