CHICAGO — H. Ty Warner, the billionaire creator of Beanie Babies plush toys, avoided a prison sentence for hiding income from U.S. tax collectors in a Swiss bank account.

Warner was sentenced Tuesday to two years of probation for tax evasion by U.S. District Judge Charles Kocoras in Chicago. He must also perform a total of 500 hours of community service for three schools, the judge said.

Warner, the founder of toymaker Ty, Inc. and Ty Warner Hotels & Resorts, failed to report more than $24.4 million in gross income to the Internal Revenue Service from 1999 to 2007, according to an agreement signed with prosecutors on Oct. 2, when he pleaded guilty to a single count of tax evasion based on his 2002 liabilities.

“I never realized the biggest mistake of my life would cost me the respect of those closest to me,” Warner, 69, said in court Tuesday. “I am truly sorry.”

Warner is among more than 100 people including bankers, lawyers and advisers prosecuted during the past five years in a U.S. crackdown on offshore tax crimes. Grave marker and monument maker Peter Troost last year was sentenced to a year and a day in prison by a judge in the same courthouse after admitting he evaded taxes on more than $3.3 million in income.

A resident of the Chicago suburb of Oak Brook, Ill., Warner has a net worth of about $1.7 billion. He has donated $140 million in cash and toys to various charities and organizations, his lawyers said in a pre-sentence brief filed on Dec. 31.

Before passing sentence, the judge read letters of support for Warner from people who described some of the billionaire’s charitable deeds.

“Society will be best served by allowing him to continue his good works,” Kocoras said.

Advisory federal sentencing guidelines called for a prison term of 46 months to 57 months. Warner’s lawyers asked for probation and community service, saying their client’s conduct constituted a single deviation from an otherwise law-abiding life in which he’s paid $1 billion in taxes.

Warner has paid a civil penalty of $53 million and filed amended tax returns for the years 1999 to 2008, his lawyers said. He has also paid $14 million in back taxes and interest, prosecutors said.

From 1996 to 2008, Warner parked some of his money first at UBS in Switzerland and then at Zuercher Kantonalbank, failing to tell his own accountants of those accounts, according to court papers. By 2008, the balance of his undisclosed account exceeded $107 million, Assistant U.S. Attorney James Conway told Kocoras in October.

Warner failed to pay almost $5.6 million in taxes on the undeclared income hidden in those accounts from 1999 to 2007, prosecutors said in their pre-sentence brief filed on Jan. 7.

“The judge heard from many people who have benefited from Ty’s quiet generosity over the years, and he crafted a sentence that allows Ty to continue to make amends in a way that most benefits society,” his lawyer Gregory Scandaglia said in a statement after Tuesday’s hearing.