gen3ric-labs
← Projects

Project · Oct 2026 · with Claude

Four Pillars chart generator

Enter a birth date and time and get the full BaZi chart: the four pillars, hidden stems, ten gods, five-element balance and luck pillars. It runs entirely in your browser.

Everything is calculated in your browser, including the image export. Nothing you enter is sent anywhere, saved, or put in the address bar. Reloading the page clears it. More information below covers the method and its limits.

Labels:

More information

A Four Pillars (BaZi, "eight characters") chart turns a birth date and time into four stem-and-branch pairs, one each for the year, month, day and hour. This section explains what the generator shows, how it gets there, and where results can differ from other tools.

How to read the chart

The building blocks

Ten heavenly stems and twelve earthly branches pair up in a repeating cycle of sixty. Each carries an element, and stems also carry a polarity.

StemsElementPolarity
甲 乙Woodyang, yin
丙 丁Fireyang, yin
戊 己Earthyang, yin
庚 辛Metalyang, yin
壬 癸Wateryang, yin
BranchAnimalElementHoursHidden stems
子RatWater23:00–01:00癸
丑OxEarth01:00–03:00己 癸 辛
寅TigerWood03:00–05:00甲 丙 戊
卯RabbitWood05:00–07:00乙
辰DragonEarth07:00–09:00戊 乙 癸
巳SnakeFire09:00–11:00丙 庚 戊
午HorseFire11:00–13:00丁 己
未GoatEarth13:00–15:00己 丁 乙
申MonkeyMetal15:00–17:00庚 壬 戊
酉RoosterMetal17:00–19:00辛
戌DogEarth19:00–21:00戊 辛 丁
亥PigWater21:00–23:00壬 甲

The branches also mark the twelve two-hour blocks of the day. The generator uses the hours in the table, in local clock time.

The ten gods

Relative to the day master, every other stem is one of five relationships, split by whether its polarity matches. The card labels come from this table.

Relationship to the day masterSame polarityOpposite polarity
Same elementFriend 比肩Rob Wealth 劫财
Element the day master producesEating God 食神Hurting Officer 伤官
Element the day master controlsIndirect Wealth 偏财Direct Wealth 正财
Element that controls the day masterSeven Killings 七杀Direct Officer 正官
Element that produces the day masterIndirect Resource 偏印Direct Resource 正印

How it is calculated

Calendar logic with solar terms is easy to get subtly wrong, so the generator does not hand-roll it. It uses the open-source lunar-javascript library (MIT license, bundled with this site) for the pillars, hidden stems, ten gods and luck pillars, and adds the element counts, the boundary warnings and the drawing on top.

I tested the port against reference data from the Python sibling, lunar-python: 824 charts (random dates from 1901 to 2099, month and year boundaries at the exact minute of each solar term, and the edges of the two-hour blocks around 23:00), 320 late-Zi births under both conventions, the annual and monthly pillars for 14 sample years, and the full ten-gods table. Every field matches. I also spot-checked the equation of time against published values and tested the solar-time arithmetic, including crossing midnight and New Year.

Those libraries share an author and a method (the Shouxing astronomical algorithm), so agreement between them shows the port is faithful, not that the method is right. To check the method itself I added a test that shares neither. It computes the moment the Sun's apparent ecliptic longitude reaches each multiple of 15 degrees straight from NASA's JPL DE440s planetary ephemeris, using Skyfield, and recomputes the pillars from first principles: the day pillar from a Julian-day formula, the hour pillar from the "five rats" rule, the month stem from the "five tigers" rule, and the year and month changes from those solar terms. For 1901 to 2050, all 1,800 month-starting solar terms agree with the calendar tables to within 45 seconds (usually within a couple), and tens of thousands of random and boundary instants give the same pillars. The only differences are minutes that fall inside those few seconds of disagreement, which is why a birth within a minute or two of a solar term can come out differently in different tools. Another implementation of the Shouxing method, sxtwl, agrees with the library to within 55 seconds.

Conventions I chose

Where results can differ

What this is not

I treat Four Pillars as a traditional, rule-based system that is worth understanding, not as a forecast. This page does the calculation and the labeling. It does not interpret the chart or predict anything.

Privacy

The page's scripts make no network requests with what you type, set no cookies and use no browser storage. Image export happens in your browser too. The birth date is never added to the address bar, so a link or bookmark to this page never contains it. The site's web server logs ordinary page requests, as any server does, but your inputs are never part of them because they stay in the page.

Credits

Calendar and BaZi calculations by lunar-javascript by 6tail (MIT). Chart drawing, element counting, solar-time adjustment, comparison, export and this page were built with Claude. The step-by-step write-up walks through the same chart for a fictional sample person and how the first version was built.