Amid mounting antiforeign sentiments, demonstrators burned down the Iranian headquarters of Grumman Corp., the U.S.-based defense contractor, today during clashes with troops at Isfahan, about 500 miles south of here.

Six Americans escaped from the four-story structure, and there were no injuries in the firebomb attack, officials said.

The Tehran homes of an American and a British diplomat were firebombed last night, but there were no injuries. Western officials said the attacks. which added to a list of nearly two dozen such incidents in recent weeks, appear designed to frighten foreign residents into leaving Iran.

The attacks came as Iran is witnessing a major exodus of expatriates. Hundreds of U.S. dependents are being flown out of this turbulent capital.

"People are leaving all the time," said an American resident of Isfahan on his way out of the country at Tehran's airport.

The West in general, and particularly the United States and Britain, have incurred the wrath of many Iranians who oppose Shah Mohammad Reza Pahlavi and feel he is being propped up by foreign powers.

Resentment over the higher salaries earned by most foreigners here has also aggravated existing xenophobic tendencies.

But even non-Westerners and nonforeigners, including at least 3,000 Indians and several thousand Iranian Jews, have been flying out of the country in the present atmosphere of fear and foreboding.

Since dawn today, thousands of cars carrying Iranian families have been leaving Tehran on main roads leading in all directions. It was unclear whether this exodus was linked with the expectations of trouble Sunday and Monday or whether the Iranians were simply taking advantage of the 4-day holidays.

An estimated 10 to 15 percent of the 45,000 Americans living in Iran have already left, and more flights are scheduled during the final countdown to the December 10-11 deep mourning of Ashura, a time massive anti-government demonstrations are planned by the religious and political opposition.

Dependents of American diplomats and military advisers are being offered free flights aboard U.S. transpart planes, although American officials say that there is no evacuation and that departure is "strictly voluntary."

About 600 dependants of U.S. government employes are due to fly out Saturday, sources said.

The U.S. ambassador to Iran, William H. Sullivan, is understood to have advised against such flights to avoid the impression of an American pullout.

Several American companies are sending employes and dependents out on special charter flights -- to return when the turmoil abates. The biggest U.S. employer in Iran, Teras-based Bell Helicopter International, is paying the way of any personnel who want to leave. Westinghouse Corp. has evacuated its entire staff and dependents -- 268 people in all -- until at least January, U.S. sources say. General Electric is said to be doing the same.

The majority of the estimated 500 U.S. firms in Iran, however, including Grumman, have no such plans. Thousands of their employes and dependents are leaving but many would have left anyway for Christmas and New Year's vacation.

Their exits are undoubtedly being hastened by the present crisis, especially by the closure of schools last week for the second time -- virtually wiping out the entire first semester. They will also be gone longer than usual, but most plan to return.

"My wife and I booked our flight for Christmas vacation two months ago, but now we're planning to stay away until the situation becomes clear," said an American shipping company employe. "I'm leaving my belongings here. I just hope they'll still be here when I get back."

Both Bell Helicopter and Grumman have contracts with the Iranian armed forces to train servicemen to fly and maintain the billions of dollars' worth of aircraft the firms have sold to the shah. Thus their employes have become principal targets for anti-shah radicals, especially in Isfahan, where they make up a vast, conspicious majority of the city's more than 12,000-strong American community.

Since the anti-shah protests began in September, the size of the American community in Isfahan has dwindled to 8,000.

Iran has bought 88 F-14 jet fighter planes equipped with the top-secret Phoenix missile from Grumman and some 500 attack helicopters from Bell.

[In Washington, government officials said they had received a report that some of the U.S. weaponry supplied to Iran had been sabotaged. No details were immediately available.]

At Tehran's Mehrabad Airport, 3,000 to 4,000 people are flying out every day, up to 40 percent of them estimated to be Iranians. Many are members of religious minorities, notably Jews and Armenian Christians who fear religious persecution should Moslem leaders come to power. Shiite Moslem opposition leaders have repeatedly declared that they respect the rights of minorities, but doubt persists.

"Most Iranian Jews like the shah because they feel that if he goes, the situation could become dangerous for them," said Iraj Afshari, a 31-year-old Jewish merchant. "We've been here a long time and Iran has been good to us, but now we're worried about what's happening."

He was standing in line with his brother, sister-in-law and their children -- bound for Israel and planning to stay until they feel it is safe to come back. About 1,000 other Iranian Jews were massed at one end of the main airport terminal. Many inched their way toward the El Al counter with carts piled high with suitcases and cardboard boxes, indicating plans for prolonged, if not permanent, stays.

"We're not going forever," said a middle-aged shopowner accompanied by his wife and two children. "We plan to return when the situation is calm."

Periodically an airline official would climb up on one of the carts and tell the jostling crowd the latest flight information through a bullhorn and ask people not to shove.

The throng also included Israeli citizens who have been advised to leave by their government.

"There is strong anti-Israeil feeling here now," he said. He cited leaflets claiming Israeli troops were helping the shah and remarked that the shah was selling oil to Israel to allow it to "keep up the war against the Arabs."

According to knowledgeable sources, all but about 300 of the 1,100 Israeli nationals living in Iran up to a few weeks ago are gone, although less than 10 percent of Iran's estimated 75,000 Jews have left.