“He attempted to assassinate the President of the United States, Donald J. Trump,” prosecutor Jocelyn Ballantine told the court.
The suspect, who was present in court without shackles, is also charged with discharging and transportation of a firearm.
Allen has not yet entered a plea.
Judge Matthew Sharbaugh ordered him held pending further proceedings, with another detention hearing set for Thursday.
Allen's lawyer, Tezira Abe, said her client has no prior criminal record.
Earlier in the day, White House Press Secretary Karoline Leavitt called the shooting an assassination attempt against Trump.
The shooting occurred at the White House Correspondents' Association Dinner. Trump attended the event for the first time in his two terms. The US president announced that he and members of his cabinet were safe and that the attacker had been detained. Authorities have named the suspect as Cole Thomas Allen, a 31-year-old California resident.