In an interview with the Sun ahead of his visit to the UK, Mr Trump said: “I think Boris would do a very good job.”
The US president said other candidates had sought his endorsement, adding: “I could help anybody.”
His comments came as Home Secretary Sajid Javid became the latest leadership contender to say he was prepared to leave the EU with no deal.
Writing in the Daily Mail, Mr Javid ruled out holding another referendum, an early general election or revoking Article 50 to end the Brexit process.
‘Very talented person’
As the UK braces for Mr Trump’s visit with a multi-million-pound security operation, Mr Trump said he had been paying close attention to the Tory leadership contest, which will decide the UK’s next prime minister.
He said: “I actually have studied it very hard. I know the different players. But I think Boris would do a very good job. I think he would be excellent. I like him. I have always liked him.
“I don’t know that he is going to be chosen but I think he is a very good guy, a very talented person.”
Mr Johnson has not responded to Mr Trump’s endorsement, and has been critical of the US president in the past.
In 2015 the then-mayor of London said Mr Trump’s remarks about alleged “no-go areas” of London “betray a quite stupefying ignorance”, and made him “unfit to hold the office of president of the United States”.
He added that he “wouldn’t want to expose Londoners to any unnecessary risk of meeting Donald Trump”.
And when Mr Trump’s administration attempted to bar people from entering the US from Muslim countries in 2017, Mr Johnson said the policy was “divisive and wrong”.
But in April 2018 Mr Johnson said it was “fantastic news” that Mr Trump was coming to Britain “at last”, for a working visit.
In May last year he was recorded saying Mr Trump could do a better job of Brexit negotiations, as the UK’s strategy lacked “guts”.
“other people” had asked him for endorsements and added: “I could help anybody if I endorse them.”
Mr Trump said he also looked favourably on Foreign Secretary Jeremy Hunt, telling the Sun: “Yup, I like him.”
But he said Environment Secretary Michael Gove had been wrong to apparently criticise him over Iran.
Mr Gove said in an interview that “sabre rattling of the kind that some have advocated is not the way forward”.
Both the UK and the US would benefit from pressure on the Middle Eastern nation, Mr Trump said, “so he should be all for that”.
Who will replace Theresa May?
The winner of the contest to lead the Conservative Party will become the next prime minister.
Having previously said he was “surprised how badly” Brexit negotiations went, Mr Trump told the Sun the UK “allowed the European Union to have all the cards”.
“It is very hard to play well when one side has all the advantage,” he said.
He said the negotiators failed to put pressure on the EU, adding: “They didn’t give the European Union anything to lose.”
Mr Trump responded to comments made by the Duchess of Sussex, who has been critical in the past of the US president.
Ahead of the 2016 US presidential election, LA-born Meghan backed Mr Trump’s rival Hillary Clinton and suggested she would leave the US if he won.
When asked by the Sun about the comments, Mr Trump said he had not been aware of them, adding: “What can I say? I didn’t know that she was nasty.”
But Mr Trump said Meghan would make “a very good” American princess, adding he thought it was “nice” she had joined the Royal Family.
The US president will arrive in the UK on Monday for a state visit, during which he will meet members of the Royal Family, including the Queen and the Duke of Sussex.
But Meghan, who gave birth to the couple’s first child, Archie, in early May, will not be present.
As with last year’s visit, demonstrations against the US president are planned.
Despite the scheduled protests, Mr Trump told the Sun he hoped he was “really loved” in the UK.
“I don’t imagine any US president was ever closer to your great land,” he said.