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:
AI Multi-Agent Stock Trading System: GPT-5 and Claude 4.5 Sonnet
What to Eat: AI Recipes and Meal Planning You Can Self-Host
O3Cloud: High-Speed Access to China for Overseas Users – 30-Day Free Trial
FossFLOW: Offline-Ready Isometric Diagram Builder for the Browser
AI-Powered Stock Research Generator with Automated Financial Charting
Scira: The Minimalist AI Search Engine for Grok, Claude, and Beyond
AingDesk: Run Local AI Models and Build a Private Knowledge Base
Gmail AutoAuth MCP Server: Control Gmail via Claude Desktop
Zotero PDF2zh: Translate Academic PDFs Directly Within Zotero
IOPaint: Free Open-Source Image Inpainting and Object Removal
How to Highlight Top 3 and Bottom 3 Bars in an Excel Chart
LVCHA VPN: Free, No Registration, No Ads & Unlimited Bandwidth