Japan's economy contracted sharply in the second quarter, data on Wednesday showed, as a nationwide consumption tax that took effect in April dragged on its recovery.

Gross domestic product (GDP) shrankan annualized 6.8 percent in the three months ending in June, compared with a Reuters forecast for a 7.1 percent contraction and after growing 6.7 percent in the first quarter.

On a quarterly basis, the economy shrank 1.7 percent, versus expectations for a 1.8 percent contraction and following a 1.6 percent expansion in the first three months of the year.

This marks the largest contraction since the January-March quarter of 2011 when the economy was hit by the impact of the March 2011 earthquake and tsunami.

The Japanese yen was steady against the U.S. dollar at 102.28 following the data, while the benchmark Nikkei index opened 0.3 percent lower.

Adam Hester | Photodisc | Getty Images

"We knew that a decline was coming. We knew that we had some circumstances in the form of the consumption tax hike so I think the data that we've seen is within expectations... slightly better," said Naomi Fink, CEO of Europacifica Consulting.

"But I would also add that many of these releases, especially the volatile ones, also tend to have volatile revisions so we might not have heard the last of these. Also the policymakers will be concerned with how quickly the GDP can bounce back and that's now the question: whether consumption and investment will normalize before the end of the year," she added.

The data underscores the challenges faced by Prime Minister Shinzo Abe, who is trying to engineer a sustainable recovery for the economy while keeping the country's mounting debt, which is among the highest in the developed world, in check.

To rein in the country's debt-to-GDP ratio, which currently stands at north of 240 percent, the government in April raised the sales tax to 8 percent from 5 percent, the first increase in 17 years. When Japan last lifted the sales tax to 5 percent from 3 percent in 1997, the economy fell into recession not too long afterwards.

Japan is ready to rebound: JPMorgan

Jesper Koll, MD & Head of Japanese Equity Research at JPMorgan Securities Japan, says growing confidence among Japanese firms, which indicates a willingness to spend, can fuel the country's recovery.

Following the data release, economy minister Akira Amari said that a decision on plans to hike consumption tax by another two percentage points to 10 percent in 2015 will hinge on various economic data ahead.

But Amari remained upbeat on the world's third-largest economy, noting a surge in GDP before a tax hike and a reactionary slump is a normal response.

He expects the country to continue a moderate recovery as the effect of the April tax hike wanes, a view shared by some analysts.

"Since the tax hike, you have a very poor May and April but June and July is starting to recover. Consumption spending has started to improve and wages are probably going to be increased because some bonuses are doing pretty well. So some people are expecting consumption spending to do well," said Peter Boardman, managing director at Tradewinds.

According to Jesper Koll, MD & head of Japanese equity research at JPMorgan Securities, business confidence is growing which could mean firms are ready to spend.

" When you look at some of the data, we got the machinery order data that is a good 15 percent increase and the key here is capital investment. The Japanese companies are reinvesting here in Japan and the confidence survey with small and medium firms suggest that confidence is growing. Japan is ready to rebound," Koll said.