"This is a very high profile case," U.S. District Judge Susan Illston noted in a written order.
She said the secrecy is needed to ensure a fair trial by reducing the likelihood that members of the public and the media might harass or try to influence the jurors.
"There is a risk that members of the public -- press or non-press -- could approach the jury and attempt to influence the verdict in the case," Illston said. In addition, Illston said, jurors could be distracted by seeing their names in print.
But the judge also ruled that jury questioning will take place in open court and that the public and the media will have access to written questionnaires that the prospective jurors fill out in advance.
Jury selection is due to begin in Illston's courtroom on March 21 with questioning of an initial group of 50 prospective jurors.
Bonds, 46, is accused of four counts of false statements and one count of obstructing justice during 2003 testimony before a federal grand jury investigating steroid dealing.
Prosecutors allege he lied when he said he never knowingly received steroids, human growth hormone or any injection from his trainer, Greg Anderson.
Bonds played for the San Francisco Giants from 1993 to 2007 and set Major League Baseball's single-season home-run record of 73 in 2001. He reached the career record of 762 during his last season in 2007.
The trial is expected to last two to four weeks.
Illston said that during the jury questioning, the prospective jurors will be identified by numbers and their names will be removed from the copies of questionnaires made available to the public and the media.
Only the questionnaires of jury candidates who are actually called to the courtroom for questioning will be made public.
A group of media organizations had asked Illston to disclose the juror names as well as the questionnaires, while Bonds' defense team asked her to keep both the names and certain other details of the questionnaires secret until after the trial.
Illston based her ruling on a 1984 decision in which the U.S. Supreme Court said there must be a "presumption of openness" in jury selection and that any restrictions in public access must be as narrow as possible and justified by compelling reasons.
Quoting from that ruling, Illston wrote, "The Supreme Court has made clear that 'the process of jury selection itself is a matter of importance, not simply to the adversaries but to the criminal justice system.'"
In Bonds' case, the judge said, "The court is faced with two compelling governmental interests that militate in favor of non-disclosure of the names of empaneled jurors: juror privacy and defendant's right to a fair trial."