Home › I Ching & Five Elements › Ming Gua Calculator (命卦 / Eight Mansions)
Ming Gua Calculator (命卦 / Eight Mansions)
Computes the personal trigram (命卦, minggua) and Kua number from the birth year and sex by the Luoshu year-star method, assigns the East Four / West Four group (东四命 dongsiming / 西四命 xisiming) and lists the four favourable and four unfavourable directions of the Eight Mansions (八宅, bazhai) school.
When to use
You need someone's Kua number, Ming Gua trigram or Eight Mansions directions from a birth date, with the year boundary at 立春 (default) or Chinese New Year.
Do not use when: You need the annual Flying Star of a year (use nine-star-feng-shui), the zodiac animal (use chinese-zodiac) or a full Bazi chart (use bazi-four-pillars).
Formula
year_star k = 1 − ((year − 1864) mod 9), wrapped into 1–9; male gua = k (5 → 2 坤); female gua = 15 − k reduced into 1–9 (5 → 8 艮); trigram by Luoshu number; directions from the Eight Mansions table
Equivalent to the popular rules male = (10 − yy) mod 9 for 19xx / (9 − yy) mod 9 for 20xx and female = (yy + 5) mod 9 / (yy + 6) mod 9 with 0 read as 9. The year changes at 立春 by default. Traditional cultural reference calculation; not a prediction and not medical, legal or financial advice.
Inputs
| Parameter | Type | Unit | Required | Description |
|---|---|---|---|---|
birth_date | date | yes | Gregorian birth date (civil date in China Standard Time), 1900–2100. | |
sex | enum: male | female | yes | Sex used by the traditional formula (male and female formulas differ). | |
boundary | enum: lichun | lunar_new_year | default lichun | Where the Chinese year changes for birthdays in January–February: 立春 (about 4 February, the feng shui convention) or Chinese New Year. |
Outputs
| Output | Type | Unit | Description |
|---|---|---|---|
gua | string | Personal trigram with pinyin, symbol and nature. | |
gua_number | integer | Luoshu number of the trigram: 1 坎, 2 坤, 3 震, 4 巽, 6 乾, 7 兑, 8 艮, 9 离 (5 is replaced by 2 for men and 8 for women). | |
group | string | East Four (东四命: 坎 离 震 巽) or West Four (西四命: 乾 坤 艮 兑). | |
element | string | Five-element attribution of the trigram. | |
favorable_directions | object | sheng_qi (生气), tian_yi (天医), yan_nian (延年), fu_wei (伏位) → compass direction. | |
unfavorable_directions | object | jue_ming (绝命), wu_gui (五鬼), liu_sha (六煞), huo_hai (祸害) → compass direction. | |
stars_legend | string | Meaning of the eight wandering stars (八游星). | |
year_used | integer | Chinese year the birth date falls in under the chosen boundary. | |
year_star | string | Luoshu star of the birth year (1864 = 一白, descending one per year). | |
disclaimer | string | Cultural-reference statement. |
Example
Female born 1990-06-01: {"birth_date":"1990-06-01","sex":"female"} → {"gua":"艮 Gen ☶ (Mountain)","gua_number":8,"group":"West Four (西四命)","element":"Earth (土)","favorable_directions":{"sheng_qi":"Southwest (SW, 西南)","tian_yi":"Northwest (NW, 西北)","yan_nian":"West (W, 西)","fu_wei":"Northeast (NE, 东北)"},"unfavorable_directions":{"jue_ming":"Southeast (SE, 东南)","wu_gui":"North (N, 北)","liu_sha":"East (E, 东)","huo_hai":"South (S, 南)"},"year_used":1990,"year_star":"1 一白 (Yi Bai, White)"}
Male born 2000-06-01: {"birth_date":"2000-06-01","sex":"male"} → {"gua":"离 Li ☲ (Fire)","gua_number":9,"group":"East Four (东四命)","favorable_directions":{"sheng_qi":"East (E, 东)","tian_yi":"Southeast (SE, 东南)","yan_nian":"North (N, 北)","fu_wei":"South (S, 南)"},"unfavorable_directions":{"jue_ming":"Northwest (NW, 西北)","wu_gui":"West (W, 西)","liu_sha":"Southwest (SW, 西南)","huo_hai":"Northeast (NE, 东北)"},"year_star":"9 九紫 (Jiu Zi, Purple)"}
GET https://tttkmbb.com/api/v1/calculate/ming-gua?birth_date=1990-06-01&sex=female
Machine access
- API:
GET https://tttkmbb.com/api/v1/calculate/ming-gua(query parameters) orPOSTwith a JSON body{"inputs": {...}} - Schema: https://tttkmbb.com/api/v1/calculators/ming-gua · Markdown: https://tttkmbb.com/yijing/ming-gua.md · JSON definition: https://tttkmbb.com/yijing/ming-gua.json
- MCP: server
https://tttkmbb.com/mcp, toolrun_calculator with calculator_id="ming-gua" - OpenAPI operationId:
calculate_ming_gua - Freshness:
static. Authentication: none. Rate limit: fair use (see rate limits).
Sources
- Wikipedia – Feng shui (Eight Mansions, 八宅) (reference)
- Wikipedia – Lo Shu Square (reference)
- Wikipedia – Bagua (reference)
FAQ
Which year applies to a January or early-February birthday?
Feng shui schools use the solar year starting at 立春 (about 4 February); someone born on 1990-01-20 is therefore counted in 1989. Choose boundary = lunar_new_year to use Chinese New Year instead.
What happens when the formula gives 5?
There is no trigram 5 (the Luoshu centre), so tradition assigns men to 坤 (2) and women to 艮 (8).
Related calculators
- Bagua Trigram Lookup (八卦) — Attributes of the resulting trigram.
- Luoshu Square (洛书) — The square whose numbers define the Kua numbers.
- Chinese Zodiac Calculator (生肖) — Zodiac animal and stem-branch of the same birth year.