Imagine walking into a room full of relatives you only see once a year. You freeze. Is that man your paternal grandmother's brother? Or is she your maternal grandfather's sister? The specific title escapes you. This is a common struggle for children and adults alike. The "Chinese Kinship Calculator" is designed to solve this. Simply type in a description of the relationship and get the correct title instantly.
Live demo: passer-by.com/relationship/
Mobile version: passer-by.com/relationship/vue/
The library is compatible with both web browsers and Node.js environments.
Browser
Include the library using a script tag:<script src="https://passer-by.com/relationship/dist/relationship.min.js">
This provides access to a global relationship function.
Node.js
Install the package via npm:npm install relationship.js
CommonJS:const relationship = require("relationship.js");
ES Module:import relationship from 'relationship.js';
The primary function is relationship. It supports two input formats: an options object or a natural-language string.
Options Mode
relationship(options)
The options object includes the following properties:
var options = {
text: '', // The target description, with links separated by '的' (e.g., '妈妈的妈妈的哥哥')
target: '', // The person from whose perspective the relationship is calculated (default is self)
sex: -1, // Your gender: 0 for female, 1 for male
type: 'default', // 'default' for the term, 'chain' for the relationship path, 'pair' for mutual terms
reverse: false, // Set to true to find what they should call you
mode: 'default',// Regional mode, which can be customized via setMode
optimal: false // Finds the shortest possible path between two people
};
Examples:
What do I call my mother's mother's brother?relationship({text: '妈妈的妈妈的哥哥'})
Returns: ['舅外公']
How should my "七舅姥爷" address me?relationship({text: '七舅姥爷', reverse: true, sex: 1})
Returns: ['甥外孙']
What are the possible definitions of "舅公"?relationship({text: '舅公', type: 'chain'})
Returns: ['爸爸的妈妈的兄弟', '妈妈的妈妈的兄弟', '老公的妈妈的兄弟']
How does a "舅妈" address an "外婆"?relationship({text: '外婆', target: '舅妈', sex: 1})
Returns: ['婆婆']
What is the relationship between an "外婆" and a "奶奶"?relationship({text: '外婆', target: '奶奶', type: 'pair'})
Returns: ['儿女亲家']
String Mode
relationship(expression)
You can also use natural phrasing such as "xxx是xxx的什么人" (Who is X to Y?) or "xxx叫xxx什么" (What does X call Y?).
Examples:
relationship('舅妈如何称呼外婆?') → ['婆婆']relationship('外婆和奶奶之间是什么关系?') → ['儿女亲家']Internal Properties and Methods
relationship.datarelationship.dataCountrelationship.setMode(mode_name, mode_data)Example:
relationship.setMode('northern', {
'm,f': ['姥爷'],
'm,m': ['姥姥'],
'm,xb,s&o': ['表哥'],
'm,xb,s&l': ['表弟'],
});
To install development dependencies:npm install
To build the minified production bundle:npm run build
To run tests (ensure you add new cases to tests/test.js):npm test
Chinese kinship terms vary significantly between northern and southern regions. This calculator aims for broad accuracy, but it may not reflect every local dialect or custom.
Some terms are inherently ambiguous and may span different generations or contexts:
Modern defaults are applied where necessary:
Sora 2 AI Watermark Remover: Remove Sora Watermarks Cleanly
What to Eat: AI Recipes and Meal Planning You Can Self-Host
Grey Deer VPN: Residential IPs for Secure Global Access
CloudRocket VPN Promo Code: 10% Discount + Upgraded 400GB/Month Plan
Tempurai Coder Review: An AI Terminal Assistant That Plans Before It Acts
AhaSpeed VPN Review: High-Speed Performance, No Ads, and Unlimited Bandwidth
Easy-AI-CodeReview: LLM-Powered Automated Code Review for GitLab
Extract2MD: Convert PDF to Markdown using Local LLMs and OCR
Notes MCP Guide: Connect Apple Notes to Claude, Cursor, and LLMs
Build Web Apps Using Only SQL: A Guide to SQLPage
Tabby Terminal: A Cross-Platform Emulator with SSH, Serial Support, and Plugins
LiveTerm: A Next.js Terminal-Style Website Template