Santos striker Gabriel Barbosa opened the scoring after 32 minutes when his shot was deflected past Japan keeper Kosuke Nakamura.
Marquinhos scored a second eight minutes later when he beat two defenders to the ball to head home a corner.
Brazil were dominant throughout and particularly in the first half when Neymar and Thiago Maia both hit the woodwork.
Barcelona striker Neymar was the outstanding performer for the home side and was ably supported by Felipe Anderson in the first half.
News that makes sense
Your trusted source for staying up-to-date with the world around you. Get free daily news updates and analysis, straight to your inbox.
The game was a useful warmup ahead of next month's Olympics when Brazil, playing at home in South America's first Olympics, will attempt to win the only international title that has so far eluded them.
Brazil face South Africa, Iraq and Denmark in the group stage.
(Writing by Andrew Downie; editing by Toby Davis)
