Huddled masses yearning to breathe free -- about 7 million to 13 million ashore and another 40,000 boatloads full -- are expected to flock here to celebrate the Statue of Liberty centennial July 4, according to New York officials.

Fears of "boatlock" notwithstanding, the Coast Guard said it can handle the crowds. But a recent briefing for city commissioners who must oversee traffic, garbage collection, police and fire protection during the four-day extravaganza elicited groans and nervous laughter at the enormity of the task.

"Oh, no, don't groan!" Mayor Edward I. Koch scolded. "Don't leave town. It's going to be terrific!"

The celebration is to feature the largest fireworks display in the nation's history, a parade of tall ships and naval vessels from 35 countries and a lighting ceremony for a newly renovated statue, starring President Reagan on an aircraft carrier.

French President Francois Mitterrand is expected to attend because the statue was his nation's gift. The King of Norway plans to show up because the statue's copper came from a Norwegian mine. Despite the recent ouster of Lee Iacocca from the Statue of Liberty-Ellis Island Centennial Commission, 800 Chrysler car dealers and their spouses are to view events from the chartered Queen Elizabeth II.

About 3,500 journalists are expected, although the best view may well be on television. ABC paid $10 million for exclusive rights to broadcast the opening and closing ceremonies.

Meanwhile, free enterprise flourishes. At Gateway Plaza, a 1,700-unit apartment building with gorgeous views of the harbor, resident Patricia Dunfy said, "People you haven't heard from in months are calling and asking, 'What are you doing on the Fourth?' " A neighbor, she said, was offered $4,000 to give up her apartment for the weekend.

Liberty Cafe on the East River has signed up 100 people at $1,000 each for dinner on July 4. Windows on the World, a restaurant atop the World Trade Center, began receiving calls for reservations three years ago and is booked solid. More than 4,000 people have paid $50 to $1,000 apiece to hire yachts from Sea Escapes, a broker in Newburyport, Mass., which reports calls from as far as Puerto Rico and California.

"The lady is entitled to a big party," said television producer David L. Wolper, who orchestrated the opening and closing ceremonies of the 1984 Olympic Games in Los Angeles and heads "Liberty Weekend," a private group sponsoring the festivities. "It should be an emotional experience."

Working out of makeshift headquarters at 1 Park Ave., with a staff that will grow to 300 over the next few weeks, Wolper is putting together a show that he said will cost "multimultimillions," although he will not be more exact. It is to be financed through sales of VIP tickets to opening and closing ceremonies and television rights here and abroad.

As Wolper described his "50-goose-bump event," it will be an outpouring of unexpurgated schmaltz designed to touch every patriotic nerve ending.

On opening night July 3, Reagan is to turn on a stream of lights across the harbor, culminating in illumination of the statue; a 300-voice choir aboard the carrier USS John F. Kennedy will sing "America the Beautiful"; captains of 20 tall ships will place torches, lighted in each of their countries, in a giant cauldron with the U.S. flame; popular musicians will sing; and Reagan will award a Medal of Liberty to 12 well-known immigrants, including Henry Kissinger and Bob Hope.

Meanwhile, Chief Justice Warren E. Burger will swear in 2,000 new citizens on nearby Ellis Island and, by satellite, 40,000 others in St. Louis, Miami, Los Angeles and on the steps of the Lincoln Memorial. All will be led in singing "God Bless America," and a child, winner of a nationwide contest, will read an essay on "What the Statue of Liberty Means to Me."

At the end of the 2 1/2-hour ceremony, a countdown will be broadcast over a marine radio band, and the 40,000 boats in the harbor will be told to flash their lights as the torch on the statue is lighted. Fireworks will flash. Cannon will sound.

"Symbols are what the world turns on," Wolper said, "and there is no more powerful symbol of this country than the Statue of Liberty."

On Friday, July 4, Navy battleships and aircraft carriers from 35 countries, the tall ships and 350 sailing ships will parade through the harbor. About 20,000 persons will watch from Battery City and Governors Island, where bleachers will be set aside for donors to the $230 million campaign to restore the statue and Ellis Island.

The mayor and city officials will watch from one of the Staten Island ferries. Another Staten Island ferry has been leased to the Coca-Cola company for $40,000.

That evening, the Boston Pops Orchestra will give a concert of American music with Barry Manilow, Johnny Cash and other performers at New Jersey's Liberty State Park, and the fireworks spectacular will explode from 30 barges, 10 times the number normally used for Fourth of July ceremonies here.

On July 5, a two-day "Liberty Conference" will open with scholars and writers discussing "different aspects of liberty." More than 500,000 persons are expected to attend a New York City Philharmonic concert in Central Park.

On July 6, closing ceremonies in New Jersey's Meadowlands will feature a sports salute with ice skater Peggy Fleming, gymnast Mary Lou Retton, the Harlem Globetrotters and a tug of war involving professional football players.

At Giants Stadium there, a 20-tiered stage with lasers, waterfalls and fireworks will feature 1,000 tap dancers and as many fiddlers, a 1,000-voice choir, a 1,500-member drill team, a 500-piece band, a 200-member dance troupe, Frank Sinatra, Willie Nelson, Elizabeth Taylor, Gene Kelly and more.

Only the opening and closing ceremonies are paid events. About 20,000 bleacher seats for July 4 will be sold to the public at $100 each, and complete ticket information is to be released later this month.

The celebration's "logistics are amazing, enormous, incredible," said Diane Coffey, the mayor's chief of staff. "This is probably the largest party we've ever had here, bigger than the Bicentennial, bigger than the Brooklyn Bridge" celebrations, she added.

Coffey said the city will spend more than $4.5 million dealing with what she estimates will be 7 million to 13 million visitors.

Wolper's guess is 5 million, he said, because "everyone in the city who doesn't want to go will get the hell out . . . . It is going to be a madhouse."