- The government said Japan was the fifth largest investor in the UK, with trade in goods and services worth £27.7bn last year.
- Mr Sunak said the new investment was a "massive vote of confidence in the UK's dynamic economy" from some of Japan's top firms.
Rishi Sunak has agreed new defence and economic deals with Japan in a visit to Tokyo, ahead of the G7 summit in Hiroshima.
Speaking on board the JS Izumo aircraft carrier, the PM announced a partnership featuring closer UK-Japanese co-operation between armed forces, cyber-agencies and semiconductor companies.
He also said Japanese firms would be investing almost £18bn in the UK.
But Labour said foreign investment had plummeted under the Conservatives.
The government is emphasising it sees the region providing economic opportunity for the UK post-Brexit UK, as well as working with Japan and Australia to counter the strategic threat from China.
About £10bn of the investment is coming from trading and investment business conglomerate Marubeni and is earmarked for offshore wind and green hydrogen projects in Scotland and Wales.
Similarly, Sumitomo Corporation intends to inject £4bn in offshore wind projects off the Suffolk and Norfolk coastline.
The government said both the investments would further solidify "the UK's status as a clean energy pioneer" and would help the UK achieve its net zero target by 2030.
The announcement came as Mr Sunak hosted a reception in Tokyo highlighting the strength of the UK and Japan's economic relationship ahead of the UK joining the regional CPTPP trade bloc (the Comprehensive and Progressive Agreement for Trans-Pacific Partnership).
The government said Japan was the fifth largest investor in the UK, with trade in goods and services worth £27.7bn last year.
Mr Sunak said the new investment was a "massive vote of confidence in the UK's dynamic economy" from some of Japan's top firms.
"The sky's the limit for British and Japanese businesses and entrepreneurs."
Labour's shadow international trade secretary, Nick Thomas-Symonds, pointed to figures from the Office for Budget Responsibility which predicts exports are set to fall by 6.6% this year, equivalent to a £51bn hit to the UK.
Responding to the announcement about Japanese investment, he said the "devil will be in the detail".
Aside from energy, two of Japan's largest real estate companies, Mitsubishi Estate and Mitsui Fudosan, confirmed £3.5bn for affordable housing, office space and a life-science laboratory in London.
There is also investment travelling in the opposite direction - from UK businesses into Japan.
Octopus Energy is set to invest £1.5bn in the Asia-Pacific energy market by 2027, to "speed up the region's transition to a cleaner, smarter energy system", creating 1,000 jobs in the UK.
UK consultancy Mott MacDonald will help develop an offshore wind farm in western Japan which could power more than 175,000 homes with clean energy, the government added.
Separately Mr Sunak will commit to a partnership combining British expertise and Japanese materials to boost supply chains for semiconductors.
The silicon microchips, used to produce supercomputers and AI technology, are hugely important to modern economies and there has been concern about depending on China for their production.
The UK prime minister also pledged to deploy a naval battle fleet in the Indo-Pacific region by 2025.
After agreeing the Hiroshima Accord, Japanese Prime Minister Fumio Kishida, Mr Sunak will attend the G7 summit, where the focus is expected to be on economic security and the conflict in Ukraine.
During the gathering, Mr Sunak will hold bilateral talks with France's Emmanuel Macron and India's Narendra Modi.
Speaking on the plane to Tokyo, Mr Sunak said: "Prime Minister Kishida and I are closely aligned on the importance of protecting peace and security in the Indo-Pacific and defending our values, including free and fair trade.
"The Hiroshima Accord will see us step up co-operation between our armed forces, grow our economies together and develop our world-leading science and technology expertise."
The two men had dinner together at Mr Kishida's favourite restaurant on land once owned by his grandfather. Mr Sunak attended the meal wearing socks featuring Mr Kishida's sports club - the Hiroshima Toyo Carp baseball team.
During his visit to Hiroshima, Mr Sunak will plant a tree to remember the victims of the atomic bomb, which killed an estimated 140,000 of the city's 350,000 population in 1945.