Type "Japanese castle for sale" into a search box and part of you expects Himeji to come up with a price and a mortgage calculator. It doesn't work that way. The real answer is more interesting than the fantasy, and there's a version of it you can actually buy: not the keep, but a house on the same lane the castle's own people once lived on.
Real castles aren't for sale
Japan has twelve original castle keeps still standing, the ones that came through fires, war and the Meiji-era demolition orders. Five of them, Himeji in Hyogo among them, are National Treasures. Every one of the twelve belongs to a city, a prefecture or the national government, and none of them is for sale. They sit in the same legal category as a famous temple or a protected stretch of old road. You can visit. You can't own.
Most of the other "castles" on the map are postwar reconstructions, usually concrete, put up by towns in the 1950s and 60s as museums and civic landmarks. Those belong to the municipality too. So when a headline says a Japanese castle changed hands, it's almost always a hotel built to look like one, or a private folly, not a feudal fortress.
What you actually can buy: the samurai house
Here's the part most people miss. The houses that sheltered the people who ran the castle, the samurai retainers and their families, do change hands. These are buke yashiki, samurai residences, and plenty of them still stand in the old districts below the castle walls. Some are grand, with earthen walls and a formal gate. Many are modest, and a fair number sit empty today as akiya, which is how they reach the open market at all. The way to find one on the market is to search the traditional houses for sale and narrow to a castle town. Nothing in Japanese law stops a foreign buyer taking one on. Ownership is freehold and open to foreigners the same as any other house.
Towns like Hagi in Yamaguchi and Kanazawa in Ishikawa kept whole samurai quarters more or less intact. Hagi's Horiuchi district was one of the first places Japan listed for preservation, back in 1976; Kanazawa's Nagamachi still runs lanes of earthen-walled homes along the old Onosho canal. A house on one of those streets won't make you a daimyo, but it puts you behind the same kind of wall, on the same lane, as the people who once did.

Castle towns are where the listings actually are
A jokamachi, literally the town below the castle, grew up around the lord's seat and still shapes how these places look. The old grid, the moats, the merchant rows and the temple districts tend to survive even where the keep is long gone. That's where you find kominka and machiya for sale, often a short walk from the castle itself.

Good hunting grounds include Matsumoto in Nagano, Hikone in Shiga, Inuyama in Aichi and Matsue in Shimane. Each keeps an original keep and an old town around it, and each turns up older houses for sale through the year. Prices in a castle town typically run higher than in a remote village, because the location carries its own demand, but they're still a world away from what the same history would cost in Europe.
What about the castle-style houses you sometimes see?
Every so often an unusual property surfaces: a private home built in the 1980s or 90s with turrets, white plaster and a tiled roof that mimics a keep. These are one-off builds by owners who had the idea and the budget, and they come up for sale now and then like any other house. They're not historic and they're not common, so there's no reliable way to search for one. If that's the dream, it's a matter of watching the listings and moving fast when one appears.
How to look for castle-town property
The practical route is to pick a castle town you like and search its prefecture. Filter by the location, sort for the oldest or cheapest stock, and read the listings for the words that matter to you: kominka for a traditional farmhouse, machiya for a townhouse, or a plot in the old quarter. An empty samurai house or a tired machiya near the walls will usually need work, so budget for renovation as much as for the purchase.

If owning a piece of a castle town appeals more than the keep itself, that's the honest, reachable version of the search, and there's real stock behind it most weeks of the year.