Coca-Cola Co. will have to give outsiders a look at the secret formula for Coca-Cola, a secret it has guarded fanatically for 99 years, a federal judge ruled yesterday.

The magic ingredients in Merchandise 7X, the legendary formula concocted in 1886 on which the Coca-Cola empire is built, would not be disclosed to the public, under the decision by U.S. District Judge Murray M. Schwartz of Wilmington, Del.

His ruling would limit access to the formula to attorneys and experts representing a small group of bottlers who have sued Coca-Cola in a dispute over the prices bottlers pay for Diet Coke. The bottlers say the exact formulas for "old" Coke, "new" Coke and Diet Coke are essential to resolving the case.

But if Coca-Cola Co. has its way, the formulas of all three will remain a mystery. "The company has never disclosed the secret formula for its products and that policy will not change," Coca-Cola said in a statement yesterday. "The company is now in the process of examining its various options . . . . " the statement said. A spokesman would not elaborate.

The quarrel between Coca-Cola and the dissident bottlers was triggered by the 1982 introduction of Diet Coke, the company's first product to use the name "Coke" on a product other than its standard-bearing soft drink.

The company said then that because Diet Coke was a different product than Coca-Cola, it was not bound by its existing contract with the bottlers and thus could raise the price bottlers pay for the diet drink, said Bill Schmidt, a bottler in Elizabethtown, Ky. Schmidt heads the Bottlers of Coca-Cola U.S.A., which has taken the company to court.

The amount of money involved in the pricing dispute is substantial, Schmidt said. Bottlers pay between $2.73 and $3.26 a gallon for old Coke and $3.80 and $4.60 for Diet Coke, depending on whether they have signed supply contracts with the company, he said.

The issue became murkier still when Coca-Cola replaced old Coke with the new version last April, and three months later, bowed to consumer pressure and revived the Real Thing, renaming it Classic Coke.

According to Schmidt, Coca-Cola said that the existing contract with the bottlers now applied to the new Coke, even though the company had emphasized the new taste and formula it had given the product.

To the dissident bottlers, it sounded like Coca-Cola was saying that Diet Coke wasn't covered by the contract because it was different, but new Coke was covered despite its differences. Schmidt said Coca-Cola's position is that Coke "is whatever we say it is." So far as the bottlers' group is concerned, if it's brown, tastes like a cola and says "Coke" on the bottle or can, it's Coca-Cola, Schmidt said.

Coca-Cola's statement noted that the bottlers who have taken the company to court account for only 3.5 percent of total Diet Coke sales in the United States.

Schmidt said the group represents between 20 and 25 percent of the Coca-Cola bottlers in this country, most of them with small to mid-sized operations. The members of the group have refused to sign marketing contracts with Coca-Cola covering Diet Coke, but continue to receive the product from the company under a temporary truce while the litigation continues.

Schmidt himself bottles about 2 million Cokes a year, which makes him a medium-sized bottler. For his two cents worth, he liked the taste of new Coke originally, but found it lost its appeal as time went on. "I can't say which I prefer now," he said, and would venture no prediction on whether the old or new Coke will prove most popular. "I don't think the dust has settled yet," he commented, adding that he prefers Diet Coke.