KB Home, the No. 5 U.S. homebuilder, posted a wider-than-expected quarterly loss on Friday, but said it saw signs that negative trends in the housing market were moderating.

Although key economic indicators remain mixed, we are beginning to see signs that some negative housing market trends may be moderating at both the local and national levels, Chief Executive Jeffrey Mezger said in a statement.

The company's quarterly net loss narrowed to $78.4 million, or $1.03 per share, in the second quarter ended on May 31, compared with $255.9 million, or $3.30 per share, a year earlier.

Analysts on average expected a loss of 72 cents per share, according to Reuters Estimates.

Revenue fell 40 percent to $384.5 million, compared with Wall Street forecasts of $337.6 million.

The company said mortgage rates remained low, and consumer confidence appeared to be returning. But it noted that tight lending standards and job market weakness might constrain demand for homes.

(Reporting by Nick Zieminski; Editing by Lisa Von Ahn)