China has built the world’s second-biggest economy and created a middle class bigger than America’s entire population, but it faces a major problem: The people who get rich there want to put their money somewhere else.

To avoid taxes or even seizure by the government, rich Chinese have exported a stunning $1.4 trillion between 2002 and today.

China leads the world in “illicit capital flows” — we call it “money laundering” — while Russia, with $800 billion hidden outside the country, is runner-up.

So much money is fleeing China — $10 billion a month — that it’s distorting the global economy, particularly in the art market and with real-estate booms in cities like New York.

China began to crackdown on the practice in 2012, following the arrest of powerful politician Bo Xilai for bribery and corruption and his wife for murder.

Thousands of high-level confiscations have followed and this month two top oil executives, a popular television anchorman and the Bank of China itself were accused of laundering money and other forms of skullduggery.

Not all the capital fleeing is obtained from criminal activity, but shipping it out is illegal.

The Chinese cannot convert their money into foreign currencies without a permit and cannot transfer money abroad.

Bo XilaiEPA

Chinese laundering methods are not innovative, but the sheer scale is unique. The easiest method is to bribe a bank to take a deposit, then wire funds offshore.

The other option is to drive truckloads of cash into the backdoor of friendly casinos where the cash is blended in with the rest then paid out, minus a fee, as gambling winnings in another currency.

Macao and Hong Kong are semi-independent jurisdictions called Special Administrative Regions of China.

Macao has a casino industry with six times the gaming revenue of the Las Vegas Strip, and Hong Kong has obliging banks. A more appropriate label for the two would be the Special Laundering Regions of China.

In China, the cash doesn’t have to go to the casino because intermediaries called “junkets” will swap Yuan for gambling chips that can be cashed into Hong Kong or Macao currency at the casino, then wired by Hong Kong banks.

The next step is to insure that funds cross many borders to frustrate tax investigators, police or ex-wives.

The ultimate goal is to spend or buy a condo with funds from a US trust managed by a shell company in Grand Cayman, owned by another trust in Guernsey with an account in Luxembourg managed by a Swiss banker who doesn’t know who the owner is.

It wasn’t until 2013 that China’s first money-laundering convictions occurred, and these were bit players.

A 19-year-old Hong Kong delivery boy was convicted of laundering $1.7 billion in eight months through his bank account in a subsidiary of the Bank of China.

Another involved an illiterate 61-year-old woman who laundered $876 million in three years by making small deposits of cash daily in several banks.

Both netted 10-year jail sentences, and no one else was charged despite evidence they did not act alone.

But in 2014, prominent Hong Kong businessman Carson Yeung was convicted of laundering $100 million that he claimed was gambling winnings.

Carson Yeung leaves the Wanchai district court as he pleaded not guilty to money-laundering charges in Hong Kong on April 29, 2013.AFP/Getty Images

In six years, $721 million flowed into the playboy’s five bank accounts from Macao. A former hairdresser, Yeung was chair of a Cayman Islands company that owned Birmingham City Football Club in Britain.

Even more devious schemes by big shots have moved tens of billions offshore without handling cash or involving banks at all.

For instance, money managers in North America were offered inflated fees of 20% to invest billions of Chinese corporate funds abroad. The catch was that half of the fees would be paid out to shell companies owned secretly by Chinese officials to buy them condos or art.

Other tactics involve bribing officials by selling assets at a loss so they can pocket immediate profits; or wiring cash to “fronts” owned by officials or their children who wash the bribes as though they were legitimate income.

The Swiss have facilitated shenanigans for decades but have recently been caught, and fined, with other European banks for washing dirty money.

Convictions followed revelations by a Credit Suisse whistleblower that clients were urged to buy diamonds for cash then smuggle them out in toothpaste tubes to fool authorities.

Other tricks included wiring funds to anonymous credit cards. In May, the bank admitted guilt and paid a fine of $2.6 billion. So have others.

China’s economic miracle has made true the promise by former leader Deng Xiaoping that “to get rich is glorious.”

But it’s New York’s real-estate market that is basking in the glory.

Diane Francis is the author of “Merger of the Century: Why Canada and America Should Become One Country.”