For the first time, the government is publicly revealing how much hospitals charge, and the differences are astounding: Some bill tens of thousands of dollars more than others for the same treatment, even within the same city.

Why does a joint replacement cost 40 times as much at one hospital as at another across the country? It's a mystery, federal health officials say.

"It doesn't make sense," Jonathan Blum, Medicare deputy administrator, said Wednesday. The higher charges don't reflect better care, he said.

And the amounts are too huge to be explained by obvious differences among hospitals, such as a more expensive regional economy, older or sicker patients, or the extra costs of running a teaching hospital, he said.

The average charges for joint replacement range from about $5,300 at an Ada, Oklahoma hospital to $223,000 in Monterey Park, California the Department of Health and Human Services said. That doesn't include doctors' fees.

Hospitals within the same city also vary greatly. At Beth Israel Medical Center in New York, the average charge to treat a blood clot in a lung is $51,580. Down the street at NYU Hospitals Center, the charge for the same care would be $29,869.

At the Mayo Clinic in Minnesota, the list price is $16,861.

That isn't necessarily what you pay.

Medicare pays hospitals on its own fee schedule that isn't based on the listed charges, Blum said. And insurance companies routinely negotiate discount rates with the hospitals.

But patients who are uninsured can be billed the full amount. And some with private insurance may find their share of the bill is inflated as a result of a hospital's higher charges, officials said.

Blum said the Obama administration hopes that releasing the information via the website will help lead to answers to the riddle of hospital pricing — and pressure some hospitals to lower their charges.

The database also will help consumers shop around, he said.

The variations shouldn't be a surprise, since hospitals might violate antitrust regulations if they shared "proposed or negotiated rates" with each other, said Rich Umbdenstock, president of the American Hospital Association. Forty states do require or encourage hospitals to make some payment information publicly available, he said.

"The complex and bewildering interplay among 'charges,' 'rates,' 'bills' and 'payments' across dozens of payers, public and private, does not serve any stakeholder well, including hospitals," Umbdenstock said.

Consumer advocates said making the charges public is significant, even if most patients don't pay those rates.

"I think the point is to shame hospitals," said Chapin White of the nonprofit Center for Studying Health System Change.

Dr. David Goodman, co-author of the Dartmouth Atlas of Health Care, said, "It does show how crazy the system really is, and it needs some reform."

Goodman argues that hospitals should be required to go further and post the charges that patients actually pay out-of-pocket, depending on what medical coverage they have. The Dartmouth Institute for Health Policy has long found wide geographic variation in Medicare payments for the similarly ill, yet people who receive more expensive care don't necessarily receive better care. Sometimes hospitals just add tests or treatments they don't really need.

A hospital's charges are akin to a car dealership's "list price." Hospitals say they frequently give discounts to the uninsured — $41 billion in financial aid in 2011.

But some people pay full price, or try to afford it, because they don't know they can seek a discount, White said.

And even for those who do bargain, the listed charge "is the opening bid in the hospital's attempt to get as much money as possible out of you," he said.

At Suburban Hospital in Bethesda, Md. — serving an affluent community at the gates of the National Institutes of Health — the average charge for simple pneumonia was $5,284. Compare that to $79,365 at Hahnemann University Hospital in Philadelphia.

The database lists the average charges for the 100 most common Medicare inpatient services at more than 3,000 hospitals. The prices, from 2011, represent about 60 percent of Medicare inpatient cases.

"Hospitals that charge two or three times the going rate will rightfully face scrutiny," Health and Human Services Secretary Kathleen Sebelius told reporters.

And consumers will get insight into a mystifying system that too often leaves them with little way of knowing what a hospital will charge or what their insurance companies are paying for treatments, Sebelius said.

Previously, the price information that the government collects from hospitals wasn't available to the average consumer, although the data could be purchased for uses such as research, officials said.

The department also is making $87 million in federal money available as grants to states to improve their hospital rate review programs, research why hospital charges vary so much, and get more information to patients.

Todd Park, an assistant to President Barack Obama on technology issues, said he envisions entrepreneurs creating apps to help consumers compare hospitals and researchers combing through the data to explain the cost differences.

"Transparent marketplaces are more competitive, and more competitive marketplaces drive down costs," Park told reporters at the White House. "And that's certainly the hope here."