The trade data came on the heels of Reuters Tankan, which showed improvement in Japan's business sentiment in August, while the key gauge of corporate capital spending rebounded in June from the previous month's decline.
The batch of data may help ease calls for more stimulus to back the fragile nature of Japan's recovery after the world's third-largest economy logged three straight quarters of expansion to June, led by capital spending and consumption.
The Ministry of Finance data showed on Wednesday exports grew 19.0% in July from a year earlier, posting 17 straight month of gains led by U.S.-bound shipments of cars and China-bounds chip-related goods, beating economists' expectations for a 18.2% gain.
Imports rose 47.2% in July year-on-year to a record 10.2 trillion yen, driven by costs of crude oil, coal and liquid natural gas, versus a 45.7% rise expected, overwhelming exports and bringing trade deficit to 1.4368 trillion yen ($10.69 billion) in July.
The yen's fall by 23.1% from a year earlier added to higher import costs, the data showed.
Separate data showed Japan's key gauge of capital spending rose 0.9% in June from the previous month, versus a 1.3% gain expected by economists in a Reuters poll.
Compared with a year earlier, core machinery orders, a highly volatile data series regarded as a leading indicator of capital spending in the coming six to nine months, grew 6.5%, it showed.
Reflecting corporate resilience, the Reuters Tankan sentiment index for manufacturers rose 4 points to 13 in August and is seen up further to 15 over next three months.
The service-sector index rose to 19 from 14 in July and was seen steady in November helped in part by the lifting of coronavirus curbs among industries such as tourism and eateries.
($1 = 134.3800 yen)
(Reporting by Tetsushi Kajimoto; Editing by Sam Holmes)
By Tetsushi Kajimoto and Kantaro Komiya