# I Ching Hexagram Lookup (六十四卦)

> Identifies one of the 64 hexagrams (六十四卦, liushisi gua) from its King Wen number, name, two trigrams or line digits and returns its lines, trigrams, nuclear (互卦, hugua), inverse (综卦, zonggua) and opposite (错卦, cuogua) hexagrams, its Jing Fang palace (京房八宫, Jingfang bagong) with 世/应 (shi/ying) lines, and the received judgment text (卦辞, guaci).

- Calculator id: `hexagram-lookup` · Category: I Ching & Five Elements (`yijing`) · Tool name: `lookup_iching_hexagram`
- Canonical page: https://tttkmbb.com/yijing/hexagram-lookup · This document: https://tttkmbb.com/yijing/hexagram-lookup.md · JSON definition: https://tttkmbb.com/yijing/hexagram-lookup.json

## Purpose

Identifies one of the 64 hexagrams (六十四卦, liushisi gua) from its King Wen number, name, two trigrams or line digits and returns its lines, trigrams, nuclear (互卦, hugua), inverse (综卦, zonggua) and opposite (错卦, cuogua) hexagrams, its Jing Fang palace (京房八宫, Jingfang bagong) with 世/应 (shi/ying) lines, and the received judgment text (卦辞, guaci).

**Use when:** You need to identify or describe a hexagram, convert between its number, name, trigram pair and line pattern, or find its derived hexagrams and palace position.

**Do not use when:** You have moving lines and need the changed hexagram and reading rule (use hexagram-change), or you need to cast a hexagram from a date or numbers (use meihua-yishu).

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `king_wen_number` | integer |  | optional | Hexagram number 1–64 in the King Wen sequence (1 = 乾, 64 = 未济). Give exactly one of king_wen_number, name, lines or the trigram pair. (min 1, max 64) |
| `name` | string |  | optional | Chinese name (屯, 水雷屯, 乾为天; traditional forms accepted), pinyin (zhun; ambiguous pinyin such as qian or bi is rejected with the candidates) or Wilhelm/Baynes title (Difficulty at the Beginning). |
| `upper_trigram` | string |  | optional | Upper (outer) trigram, in any form accepted by bagua (坎, kan, water, ☵, 010). Must be given together with lower_trigram. |
| `lower_trigram` | string |  | optional | Lower (inner) trigram, in any form accepted by bagua. |
| `lines` | string |  | optional | Six digits from line 1 (bottom) to line 6 (top): 1/0 for yang/yin, or 6/7/8/9 (老阴/少阳/少阴/老阳) as produced by yarrow or coin casting. |

## Output

| Field | Type | Unit | Description |
| --- | --- | --- | --- |
| `number` | integer |  | Position 1–64 in the King Wen sequence. |
| `name_cn` | string |  | Simplified Chinese name. |
| `full_name_cn` | string |  | Traditional descriptive name with the trigram images, e.g. 水雷屯 or 乾为天. |
| `pinyin` | string |  | Hanyu pinyin of the name. |
| `english` | string |  | Wilhelm/Baynes title. |
| `symbol` | string |  | Unicode hexagram symbol (U+4DC0 + number − 1). |
| `lines` | string |  | Six digits from line 1 to line 6; 1 = yang, 0 = yin. |
| `lines_text` | string |  | Traditional line titles from bottom to top, e.g. 初九 六二 … 上六. |
| `upper_trigram` | string |  | Outer trigram (lines 4–6) with pinyin, symbol and nature. |
| `lower_trigram` | string |  | Inner trigram (lines 1–3) with pinyin, symbol and nature. |
| `nuclear_hexagram` | string |  | Hexagram formed by lines 2-3-4 (lower) and 3-4-5 (upper). |
| `inverse_hexagram` | string |  | The hexagram turned upside down (lines reversed). |
| `opposite_hexagram` | string |  | All six lines flipped yin↔yang. |
| `palace` | string |  | Jing Fang (京房) palace the hexagram belongs to, with its element. |
| `palace_position` | string |  | 本宫 / 一世 … 五世 / 游魂 / 归魂 position within the palace. |
| `shi_line` | integer |  | Position (1–6) of the 世 line: 6 for the palace hexagram, 1–5 for generations 1–5, 4 for 游魂, 3 for 归魂. |
| `ying_line` | integer |  | Position of the 应 line, three lines away from 世. |
| `judgment_text` | string |  | Received classical judgment text of the 周易 (Zhouyi), simplified characters. |
| `sequence_pair` | string |  | Partner hexagram in the King Wen pairing (2n−1, 2n): its inverse, or its opposite for the eight symmetric hexagrams. |
| `binary_value` | integer |  | Integer of the six bits with the top line as the most significant bit (乾 = 63, 坤 = 0). |
| `notes` | string |  | Conventions used. |

## Formula

`lower trigram = lines 1–3, upper trigram = lines 4–6; nuclear = lines 2,3,4 + 3,4,5; inverse = reversed line order; opposite = each line flipped; binary_value = Σ line_i · 2^(i−1); 应 = 世 ± 3`

King Wen order, names and lines from the received text; English titles from Wilhelm/Baynes (1950). Palaces follow the Jing Fang (京房) system: flip lines 1–5 of the palace hexagram in turn, flip line 4 back for 游魂 and restore the lower trigram for 归魂. Traditional cultural reference calculation; not a prediction and not medical, legal or financial advice.

## Data Sources

- Wikipedia – List of hexagrams of the I Ching — https://en.wikipedia.org/wiki/List_of_hexagrams_of_the_I_Ching (reference, retrieved 2026-09-24)
- Wikipedia – King Wen sequence — https://en.wikipedia.org/wiki/King_Wen_sequence (reference, retrieved 2026-09-24)
- Wilhelm R. & Baynes C. F. (1950) The I Ching or Book of Changes, Bollingen Series XIX, Princeton University Press — https://press.princeton.edu/books/hardcover/9780691097503/the-i-ching-or-book-of-changes (textbook, retrieved 2026-09-24)

Data freshness: `static`. Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output.

## API

- `GET https://tttkmbb.com/api/v1/calculate/hexagram-lookup?`
- `POST https://tttkmbb.com/api/v1/calculate/hexagram-lookup` with JSON body `{"inputs": {…}}`
- Response: unified envelope (`success`, `request`, `result.values`, `result.units`, `sources`, `freshness`, `timestamp`, `next_actions`, `links`); see https://tttkmbb.com/docs/response-format.md
- Schema: https://tttkmbb.com/api/v1/calculators/hexagram-lookup · OpenAPI operationId `lookup_iching_hexagram` in https://tttkmbb.com/openapi.json
- Authentication: none. Rate limit: fair use, see https://tttkmbb.com/docs/rate-limits.md.

## MCP

- Server: `https://tttkmbb.com/mcp` (Streamable HTTP, JSON-RPC 2.0, no auth)
- Tool: `lookup_iching_hexagram` (dedicated) or `run_calculator` with `{"calculator_id": "hexagram-lookup", "inputs": {…}}`

## Example

- Hexagram 1 乾: inputs `{"king_wen_number":1}` → `{"name_cn":"乾","symbol":"䷀","lines":"111111","nuclear_hexagram":"1 乾 Qian (The Creative) ䷀","inverse_hexagram":"1 乾 Qian (The Creative) ䷀","opposite_hexagram":"2 坤 Kun (The Receptive) ䷁","palace":"乾宫 (Qian palace, Metal)","palace_position":"本宫卦 (Bengong, palace hexagram)","shi_line":6,"ying_line":3,"binary_value":63}`
- Lines 100010 (屯): inputs `{"lines":"100010"}` → `{"number":3,"name_cn":"屯","full_name_cn":"水雷屯","upper_trigram":"坎 Kan ☵ (Water)","lower_trigram":"震 Zhen ☳ (Thunder)","nuclear_hexagram":"23 剥 Bo (Splitting Apart) ䷖","inverse_hexagram":"4 蒙 Meng (Youthful Folly) ䷃","opposite_hexagram":"50 鼎 Ding (The Cauldron) ䷱","palace":"坎宫 (Kan palace, Water)","palace_position":"二世卦 (Ershi, second generation)","shi_line":2,"ying_line":5,"sequence_pair":"4 蒙 Meng (Youthful Folly) ䷃","binary_value":17}`

```
GET https://tttkmbb.com/api/v1/calculate/hexagram-lookup?king_wen_number=1
```

## Limitations

You have moving lines and need the changed hexagram and reading rule (use hexagram-change), or you need to cast a hexagram from a date or numbers (use meihua-yishu). King Wen order, names and lines from the received text; English titles from Wilhelm/Baynes (1950). Palaces follow the Jing Fang (京房) system: flip lines 1–5 of the palace hexagram in turn, flip line 4 back for 游魂 and restore the lower trigram for 归魂. Traditional cultural reference calculation; not a prediction and not medical, legal or financial advice. All values are computed from the formula above; no measurement or live data is involved.

## FAQ

**In which order are the six digits?**

Bottom to top: the first digit is line 1 (初), the sixth is line 6 (上), the order in which a hexagram is built when casting. Digits 6/7/8/9 are read as old yin / young yang / young yin / old yang, so 6 and 8 are yin and 7 and 9 are yang.

**What are the nuclear, inverse and opposite hexagrams?**

The nuclear hexagram (互卦) uses lines 2-3-4 as its lower and 3-4-5 as its upper trigram; the inverse (综卦) is the hexagram read upside down; the opposite (错卦) flips every line. The King Wen sequence pairs each hexagram with its inverse, or with its opposite when the inverse is itself.

**What do 世 and 应 mean?**

In the Jing Fang palace system each hexagram has a self line (世爻) whose position depends on its generation within the palace (6, 1–5, 4 for 游魂, 3 for 归魂) and a response line (应爻) three positions away; Liu Yao charts use them.

## Related

- [Hexagram Change Calculator (变卦)](https://tttkmbb.com/yijing/hexagram-change.md) — Apply moving lines to get the changed hexagram and the reading rule.
- [Bagua Trigram Lookup (八卦)](https://tttkmbb.com/yijing/bagua.md) — Attributes of the two component trigrams.
- [Liu Yao Hexagram Chart (六爻)](https://tttkmbb.com/yijing/liuyao.md) — Six-line (六爻) chart with 世/应 and palace for divination records.
