John Egan Shea, 76, an attorney in Washington for almost 40 years, died Sunday at St. Mary's Hospital in Palm Beach Gardens, Fla. He had a heart ailment.

Mr. Shea was born in Newport, R.I. He graduated from Holy Cross College in Worcester, Mass., and then moved to Washington to study law at Georgetown University and to work for the Treasury Department. He began with the old Bureau of Internal Revenue in 1927, earned his law degree in 1931, and continued at Treasury, where he worked in the office of the Secretary, until 1941.

In that year he became general counsel to the Southern Pacific Railroad in San Francisco. He returned to Washington about 1944 and joind the law firm of Hughes, Prettman and Awalt. In the late 1940s, he helped form the firm of Sullivan, Bernard, Shea and Kenney, later Sullivan, Shea and Kenney.He retired in 1970 and moved to Palm Beach Gardens.

Mr. Shea was the first president of the Sumner, Md., Citizens Association. He also had been president of the Holy Cross Club of Washington and a member of the Ancient Order of Hibernians and the Friendly Sons of St. Patrick.

He had been a member of the parish of the Annunciation Church in Washington, where he lived from 1956 to 1970.

Survivors include his wife, Mary Gormley Shea, of the home in Palm Beach Gardens; six daughters, Mrs. James C. Gaffney, of Washington, Mrs. George W. Lindley, of Duncan, Okla., Mrs. Cyril Thiel Jr., of Southfield, Mich., Mrs. Harry T. O'Hare III, of Belmont, Mass., Mrs. James Blaszak, of Annandale, and Mrs. Robert Scott, of San Antonio, Texas; two sisters, Mrs. Robert Armstrong and Mrs. Edmund J. Sullivan, both of Newport, R.I., and 10 grandchildren.