Comey turned himself in on two charges, including threatening the life of the president and transmitting threats across state lines.
The former FBI director did not speak during a brief court appearance.
His lawyer Patrick Fitzgerald said he would argue that the case is a vindictive prosecution, meaning it was brought to punish Comey for exercising his legal rights.
US Magistrate Judge William Fitzpatrick of the Eastern District of Virginia ordered Comey released and did not impose any special conditions.
His next court appearance is expected in North Carolina, where a federal grand jury returned the indictment on Tuesday.
Members of Comey's family entered the courthouse shortly before the proceeding began.
Comey has said he is innocent and will fight the accusations in court.
Comey listened in court on Wednesday as Fitzpatrick read aloud the charges, which carry a maximum penalty of five years in prison.
The charges relate to a post Comey made on Instagram last May showing seashells arranged on a beach to form the numbers "86 47".
The number "86" is a slang term originating in the restaurant industry that can mean to "get rid of" or throw someone out.
Forty-seven is a possible reference to Trump as the 47th US president.
The indictment alleged that a reasonable recipient of the message would interpret it as a threat to Trump.
Trump told reporters on Wednesday that he viewed "86" as a "mob term".
"People think of it as something having to do with disappearing but the mob uses that term to say when they want to kill somebody," Trump told reporters at the White House.
Asked whether he thought the post put his life in danger, Trump responded, "Probably. I don't know".
Comey deleted the post shortly after it was published, saying he viewed it as a political message and was not aware that the number could be associated with violence.
Comey, a longtime Trump foe, has now faced two criminal cases from the Justice Department during Trump's second administration.
A previous case accusing him of lying to Congress was dismissed by a federal judge.