Zhangbi Ancient Fortress: Underground Castle of Shanxi

Hidden in the loess hills of Jiexiu, Shanxi, the Zhangbi Ancient Fortress is one of the most unusual surviving fortifications in northern China. Most foreign travelers know Pingyao, but few realize that a 40-minute drive south reveals a complete walled village sitting on top of a three-level military tunnel network carved more than 1,400 years ago. We’ve sent travelers here as a half-day add-on to a Pingyao trip, and almost every one of them comes back saying the underground section was the most memorable part of their Shanxi itinerary. The site is compact, inexpensive, and genuinely unlike the temples and city walls that fill most Shanxi routes. If you want a destination that surprises even seasoned China visitors, this is it.

Narrow earthen lanes of Zhangbi Ancient Fortress village with Ming and Qing courtyard houses

The Zhangbi Ancient Fortress was built during the Sui and Tang dynasties as a defensive strongpoint, and its above-ground plan follows a star-aligned layout that locals still call the “Kaiming constellation” design. The village covers barely 0.12 square kilometers, enclosed by compact rammed-earth walls that rise only about ten meters, yet inside the small maze of lanes you find temples, wells, and family courtyards packed tightly together. What makes the site genuinely unique, though, is what lies beneath: a 10,000-meter tunnel system with three stacked levels, complete with barracks, stables, granaries, wells, and command rooms, all linked by narrow passages and disguised trapdoors. This is the Zhangbi underground castle that gives the fortress its reputation, and walking through it feels like stepping into a medieval military engineering manual.

A short history of the tunnels

Scholars date the earliest tunnels to the Sui dynasty (581–618), a turbulent period when local warlords needed hideouts that enemy cavalry could not find. Tradition links the fortress to the “Zhang” and “Bi” stars of the Twenty-Eight Mansions, which is why the name Zhangbi is written with those two characters. The builders dug three levels: a shallow layer about two to three meters down for daily movement, a middle layer five to six meters down for storage and shelter, and a deep layer eight to ten meters down used in emergencies. Only about one kilometer of the network is open to visitors today, but that stretch is enough to show how the shafts, wells, and ventilation chimneys interlock. On our last visit, a local caretaker demonstrated how a hidden trapdoor could seal a passage in seconds, and the travelers with us agreed it was the single most memorable moment of the trip.

Things to do at Zhangbi Fortress

The most rewarding things to do at Zhangbi Fortress begin the moment you pass through the south gate. Start above ground. The village is small enough to cross on foot in fifteen minutes, but allow at least an hour to notice details: the rare Khan Temple (Khan Miao), the only one of its kind in China, the faded murals inside the Wenguang Temple, and the old private school where village children once studied. The lanes are deliberately crooked, a defensive trick meant to slow invaders and confuse enemy troops unfamiliar with the layout.

Then descend. A stone stairway near the center drops you into the first tunnel level, roughly two meters high and lit by sparse bulbs. The passages are cool year-round and smell of damp earth. You will see niches where oil lamps once burned, brick-lined wells that connect all three levels, and a central shaft that doubles as a ventilation chimney and a place to drop stones on intruders. The lowest level is the oldest and quietest. Our guides tell us to watch for the small side chambers that served as emergency storerooms, and for the brick troughs that once held water for trapped defenders.

Photography is permitted throughout, but bring a phone light for the lower tunnels because the lighting is intentionally dim. Plan to spend roughly two and a half hours total: one hour above, ninety minutes below, and time for tea at one of the family-run courtyards near the gate. If you enjoy slow travel and hands-on history, this is the kind of place that rewards curiosity.

Best time to visit Zhangbi

The best time to visit Zhangbi is late April through May, when the loess hills turn green and the temperature sits comfortably in the high teens Celsius, and again in September and October, when the autumn light makes the grey brick glow and the tourist numbers drop after the National Day week. Summer is workable but can be hot and crowded on weekends; the tunnels stay cool, which is a small consolation. Winter is the quietest season and the tunnel is atmospheric, but the exposed village lanes get bitterly cold and some family teahouses close. For a broader seasonal picture across the province and beyond, our best time to visit China guide breaks down the months by region.

How to get to Zhangbi Fortress

Knowing how to get to Zhangbi Fortress saves you hours of confusion, because the site sits off the main tourist trail. The nearest high-speed rail station is Jiexiu East, reached in about 30 minutes from Pingyao and 40 minutes from Taiyuan. From Jiexiu East you can take a taxi or a local rural bus for the final 18 kilometers, about 25 to 40 minutes depending on road conditions. Coming from Pingyao, many of our travelers book a private car through us for the round trip, which costs roughly ¥350 to ¥500 (about $50 to $70 USD) including waiting time. If you are building a Shanxi route by rail, our China high-speed train guide for foreigners explains ticket booking and station transfers in plain terms.

Practical costs and the surrounding route

Admission to the Zhangbi underground castle is ¥75 per adult in peak season and ¥60 in the low season, with a small electric shuttle from the parking lot to the gate included; children under 1.2 meters enter free. A licensed local guide who explains the tunnel’s military logic costs around ¥100 to ¥150 (about $14 to $21 USD) for a group and is well worth it. Combine Zhangbi with nearby Pingyao for a perfect two-day loop: spend the morning in the underground fortress and the late afternoon walking the Pingyao city wall. Our Pingyao ancient town guide has the hotel and timing details. If your Shanxi trip starts in the provincial capital, Taiyuan, that city covers where to stay and how to connect onward.

Food and a Shanxi angle

Zhangbi sits in the heart of Shanxi noodle country, and the fortress teahouses serve hand-pulled noodles, aged vinegar dipping sauces, and simple wheat pancakes. A bowl of knife-cut noodles (dao xiao mian) near the gate runs about ¥18 to ¥28 ($2.50 to $4 USD). We always point hungry travelers to Shanxi’s noodle and vinegar traditions so they know what to order and where the best vinegar is made. If you are extending north toward the Buddhist cave art of Datong, the Yungang Grottoes pair well with this route.

Brick passage inside the Zhangbi underground castle tunnel with ventilation shaft

Why we keep sending travelers here

On our last visit in early May, the wheat fields around the fortress were just turning green and the morning light fell perfectly across the south gate. The Zhangbi Shanxi experience is compact and the Zhangbi underground castle stays cool even in August, so it works in any warm month. Most things to do at Zhangbi Fortress revolve around the tunnel, but the village lanes above reward a slow walk too. We’ve sent travelers there ranging from backpackers to a family with two teenagers, and the tunnels worked for all of them because you control the pace: turn back at any stair if small children tire. The Zhangbi Shanxi experience is compact, affordable, and genuinely unlike anywhere else in the province, which is exactly why we include it on our Shanxi heritage routes. A comfortable sample plan is to arrive at 9 a.m., tour the village and tunnels until noon, eat noodles at the gate, and reach Pingyao by early afternoon.

The fortress is managed as a cultural heritage site, and you can read the official background on related defensive settlements of the region through the UNESCO World Heritage Centre, which documents similar fortified villages of Shanxi.