WASHINGTON — President Obama, after months of sitting on the sidelines of the rancorous contest to succeed him, is now ready to aggressively campaign for Hillary Clinton, starting with a formal endorsement of her candidacy as early as this week.

The White House is in active conversations with Mrs. Clinton’s campaign about how and where the president would be useful to her, according to senior aides to Mr. Obama.

Advisers say the president, who sees a Democratic successor as critical to his legacy, is impatient to begin campaigning. They say he is taking nothing for granted.

“I want us to run scared the whole time,” Mr. Obama told a group of donors on Friday night in Miami.