The U.S. Commerce Department released the trade data on Wednesday. The U.S. trade deficit narrowed to $40.88 billion in April from a deficit of $50.57 billion in March.
March's figure was revised up from a deficit of $51.37 billion.
Analysts had expected a trade deficit of $40.3 billion.
The decline of a deficit was driven by lower imports. Imports fell by 3.3% in April, while exports increased by 1.0%.
A stronger U.S. dollar weighs on exports as it makes U.S. goods and services less affordable abroad.
Exports to China declined 5.8%.