The U.S. economy expanded at a healthy 3.1 percent annual rate from April through June, but inflation shot up at the fastest pace in almost six years, the government reported Wednesday.

The Commerce Department said growth in the gross national product, the broadest measure of economic health, was down only slightly from a 3.4 percent increase in the first three months of the year.Inflation, however, picked up substantially during the spring, with a price index tied to the GNP climbing at an annual rate of 4.7 percent, the biggest advance since a 5.5 percent rise in the third quarter of 1982.

This inflation index, which measures a fixed selection of goods, had risen 3.5 percent in the first quarter.

Wednesday's report blamed the pickup in inflation on higher costs for a wide range of consumer goods.

While the U.S. economy is performing substantially better than had been expected at the start of the year, the more robust growth has triggered inflation fears.

Recently, Federal Reserve Chairman Alan Greenspan warned that if economic activity did not slow in coming months, the central bank was prepared to dampen demand by pushing interest rates up further. Economists worry, however, that if credit is tightened too severely it could trigger a recession next year.

But Michael Evans, head of a Washington forecasting firm, said he was not overly concerned by the rise in inflation. He said most of the price pressure came in increases for clothing and energy early in the spring. He said those gains have since been reversed.

"I don't think this is a sign that we will have higher inflation ahead," he said.

Wednesday's GNP report was accompanied by benchmark revisions in GNP data over the last three years, part of an annual review to update the data to reflect new information.

The revisions substantially boosted growth last year to an annual rate of 3.4 percent, largely because of higher consumer spending. The earlier estimate had put GNP growth last year at 2.9 percent.

The Reagan administration recently revised its estimate of growth for all of 1988 to 3 percent, when measured from the fourth quarter of last year to the fourth quarter of this.

Because the economy grew at a 3.25 percent annual rate in the first half of this year, growth could dip as low as 2.7 percent in the second half of the year and still meet the administration's target, which is in line with the expectations of many private analysts.

Many economists are expecting growth to slow in the second half of the year, in part because of the adverse effects of the severe drought in the farm belt.

Overall, GNP grew at an annual rate of $30.2 billion in the spring quarter, pushing total inflation-adjusted GNP to $3.986 trillion in the second quarter.

Much of the strength came from a $18.9 billion improvement in the country's trade deficit, the biggest narrowing of the deficit since a $24.8 billion shrinkage in the first quarter of 1980.

Also contributing to growth in the April-June quarter was a $14.4 billion rise in consumer spending, which climbed at an annual rate of 2.3 percent.