Trump has made his @RealDonaldTrump Twitter account a central, and controversial, part of his presidency.

US President Donald Trump violated the Constitution by blocking people whose views he disliked from his Twitter account, a federal appeals court ruled on Tuesday.

In a 3-0 decision, the 2nd US Circuit Court of Appeals in Manhattan said the First Amendment forbids Trump from using Twitter's "blocking" function to limit access to his account, which has 61.8 million followers.

"The First Amendment does not permit a public official who utilizes a social media account for all manner of official purposes to exclude persons from an otherwise-open online dialogue because they expressed views with which the official disagrees," Circuit Judge Barrington Parker wrote, citing several Supreme Court decisions.

Neither the White House nor the US Department of Justice immediately responded to requests for comment. The White House social media director Dan Scavino is also a defendant. Twitter had no immediate comment.

Trump has made his @RealDonaldTrump account a central and controversial part of his presidency, using it to promote his agenda and to attack critics.

His use of the blocking function was challenged by the Knight First Amendment Institute at Columbia University, as well as seven Twitter users he had blocked.

"The decision will help ensure the integrity and vitality of digital spaces that are increasingly important to our democracy," Jameel Jaffer, the Knight institute's executive director, said in a statement.

Tuesday's decision upheld a May 2018 ruling by US District Judge Naomi Reice Buchwald in Manhattan, which prompted Trump to unblock some accounts.

The Justice Department has called her ruling "fundamentally misconceived," saying Trump used Twitter to express his views, not to offer a public forum for discussion.

Parker, however, said Trump's account bears "all the trappings of an official, state-run account" and is "one of the White House's main vehicles for conducting official business."

He said Trump and his aides have characterized the president's tweets as official statements, and that even the National Archives views the tweets as official records.

Parker also found it ironic that Trump censored speech during a time when the conduct of the US government and its officials was subject to intense, passionate and wide-open debate.

"This debate, as uncomfortable and as unpleasant as it frequently may be, is nonetheless a good thing," he wrote. "We remind the litigants and the public that if the First Amendment means anything, it means that the best response to disfavored speech on matters of public concern is more speech, not less."

The case is Knight First Amendment Institute at Columbia University et al v Trump et al, 2nd US Circuit Court of Appeals, No. 18-1691.