The U.S. Senate unanimously passed legislation Thursday evening to require Supreme Court justices and federal judges to promptly post online their stock trades and financial holdings.

The bill now goes to the House, where similar legislation passed by a vote of 422-4 in December.

Republican Sen. John Cornyn of Texas and Democratic Sen. Chris Coons of Delaware, the bill’s sponsors, said increased transparency would allow litigants to detect the kind of violations of a conflict-of-interest law exposed in a Wall Street Journal investigation last year.

The Journal found that more than 130 judges broke the law by hearing cases in which they reported having a financial interest. Litigants in virtually all of the cases had no idea of the judges’ conflicts.

If enacted, the law would require the judiciary to post both the stock-trade reports and annual disclosure report forms online within 90 days of being filed. Currently, annual reports aren’t due until May of the following reporting year and periodic stock-trade reports aren’t required at all.

Congress and senior administration officials for years have had to report stock trades periodically as they occur under what is known as the Stop Trading on Congressional Knowledge Act.

“Federal judges should never have been excluded from the STOCK Act’s disclosure requirements, and this oversight has resulted in conflicts of interest that erode public trust in our judiciary,” Sen. Cornyn said in a statement. “I look forward to these important transparency and disclosure provisions becoming the law of the land.”

In recent months, Congress has been drafting legislation to address concerns over stock trades and possible conflicts of interest by federal judges and central bank officials. House Speaker Nancy Pelosi this month said she expects Democrats to reach consensus on restricting stock trading by members of Congress. Mrs. Pelosi also said she wanted any legislation to require financial disclosures from the judiciary, including Supreme Court justices. “It has to be governmentwide,” she said.

The Senate bill, the Courthouse Ethics and Transparency Act, amends the Government in Ethics Act of 1978. The reporting requirements also would apply to Supreme Court justices. Supreme Court Chief Justice John Roberts recently pushed back on congressional intervention adding requirements and said the high court has never addressed whether Congress can impose regulations on the Supreme Court. Justices nonetheless voluntarily comply with financial-disclosure rules set out for federal judges, he said.

The bill would require justices for the first time to promptly report financial transactions and stock trades as they happen, as is required for Congress and senior administration officials. Currently, judges detail their transactions in annual reports that generally don’t become available for at least a year.

Gabe Roth, who runs the judicial-ethics reform group Fix the Court, said in an email to supporters last month that the bill had briefly stalled in the Senate because of objections from lobbyists for the Administrative Office of the Courts who said “they’d need several years to set this system up (they don’t) and that knowing judges’ financial holding would lead to forum shopping (it wouldn’t.)”

David Sellers, spokesman for the Judicial Conference of the U.S., said the judiciary has taken no position on the legislation. “Fix the Court is not always the most accurate reflection of our position,” Mr. Sellers said.

Judicial resistance led to one change in the Senate bill: Senate drafters allowed for the extension of the deadline of enactment of the online database, according to congressional aides.

While the Senate bill calls for the database to be online within 180 days of the president signing the bill into law, it also allows for an extension by notifying Congress in writing seeking additional time needed to implement the law. The earlier House bill contained no such provision. It isn’t known whether the House will accept the change.

Sens. Cornyn and Coons also have added a provision to make it clear that the law would apply to bankruptcy and magistrate judges. The leading authors of the House bill, Reps. Deborah Ross (D., N.C.), Hank Johnson (D., Ga.) and Darrell Issa (R., Calif.) believed their bill applied to bankruptcy and magistrates, though it didn’t specifically name them.

Rep. Ross in a statement praised the Senate passage as a boon to transparency, accountability and trust in the American promise of blind justice. The congresswoman, however, didn’t indicate whether the House would move to pass the Senate bill as is or make amendments and work out differences in conference. “I will continue working with my House and Senate colleagues to send the best possible legislation to President Biden’s desk,” Rep. Ross said.

The Senate bill passed after routine business by unanimous consent, something that requires every senator to sign off on the bill in advance.

“The bipartisan Courthouse Ethics and Transparency Act will help ensure that our legal system is free from conflicts of interest so that everyone can have clarity and confidence when they enter a courtroom,” Sen. Coons said in a statement. “I’m glad to see this common-sense reform pass unanimously in the Senate, and I look forward to President Biden signing it into law.”