TOKYO, July 27 (Reuters) - Japan's Nikkei reversed course to end higher on Wednesday, helped by gains in heavyweight chip-related stocks, with investors remaining cautious ahead of a rate decision by the U.S. Federal Reserve later in the day.

The Nikkei inched up 0.22% to 27,715.75 and the broader Topix inched 0.13% higher to 1,945.75.

The benchmark index opened with small declines after Wall Street ended sharply lower Tuesday as a profit warning by Walmart dragged down retail shares and exceptionally weak consumer confidence data also fuelled fears about spending.

The Federal Reserve later on Wednesday is expected to announce a 0.75 percentage point interest rate hike to fight inflation, with markets pricing about a 10% risk of a larger increase.

"There won't be a major surprise from the FOMC (Federal Open Market Committee) but investors just want to confirm the outcome before making bets," said Takatoshi Itoshima, strategist at Pictet Asset Management Japan.

"After this major event, investors will look into details in each corporate outlook and selectively buying stocks."

In Japan, chip-related heavyweights Tokyo Electron and Advantest boosted the Nikkei, jumping 3.1% and 2.28%.

Defensives were strong, with the railway sector rising 1.17% to become the top gainer among the Tokyo Stock Exchange's 33 industry sub-indexes. The drug sector rose 1.12%, with Astellas Pharma climbing 3.18%.

Uniqlo clothing shop owner Fast Retailing weighed on the Nikkei the most, slipping 1.42%. Technology investor SoftBank Group lost 0.12% and materials maker Nitto Denko fell 1.35%.

Canon slipped 1.03% even as the camera maker raised its full-year operating profit forecast.

(Reporting by Junko Fujita; editing by Uttaresh.V and Elaine Hardcastle)