California’s boom-and-bust budget could soon get a big boost as companies worth billions of dollars rush onto the public markets, bringing huge tax gains for their home state.

“It will be a very impressive (initial public offering) cycle — in absolute dollar values, possibly the largest California has seen,” said Kevin Klowden, executive director of the California Center at the Milken Institute, a think tank.

All the newly minted California millionaires and billionaires from the likes of Uber, Lyft, Pinterest, Slack, Palantir and Postmates will generate a windfall; taxes are usually due when employees vest stock awards, sell shares or exercise options.

The state heavily relies on income tax for revenue, and, under its progressive tax policies, the wealthy pay proportionately more. So stock market bonanzas that make the rich richer will swell California’s coffers with taxes on exercised stock options treated as income and shares sold as capital gains. California taxes both as ordinary income at a top rate of 13.3 percent.

“IPOs mean people will be getting a lot of money which will often be taxed at the highest rate,” said Brad Williams, former chief economist at the Legislative Analyst’s Office and now a partner at Capitol Matrix Consulting. “By their nature, they create a lot of income for the state.”

They’ll also create more revenue for San Francisco, which is playing host to an unusually high number of richly valued private companies going public this year. The city no longer excludes stock options from its 0.38% payroll tax. When employees exercise their stock options, businesses pay that rate on the options’ value. San Francisco brought in $442.2 million from the payroll tax in 2017 when the rate was 0.7%. For 2018, with the rate almost halved, it projects $254.5 million. Stock options are not distinguished from salary in those amounts, and the city doesn’t have a forecast for 2019.

California, which once went overboard on spending IPO windfalls, now approaches them with a healthy amount of caution, said H.D. Palmer, spokesman for the Department of Finance. “They provide a welcome infusion of revenue into the state budget,” he said. “But we have to be mindful that one-time events like this will not happen with regularity. They are short-term in nature.”

Most IPO-related money would end up in the general fund, with some socked away in a rainy-day fund to help even out volatility. But some would be earmarked for other uses. Money generated by higher tax rates on the wealthiest Californians, set by Propositions 30 and 55, goes toward K-12 schools and community colleges and sometimes public health care (although much of it simply replaces money that otherwise would come from the general fund). Prop. 63’s 1% tax on income over $1 million goes to mental health services.

State number-crunchers haven’t yet tried to calculate what California might reap from the upcoming stock-market debuts but hope to do so soon. The best clues will come from companies’ public filings, in which they reveal how many shares are held by investors, top executives and employees, and discuss vesting schedules.

Likewise, San Francisco hopes to estimate the IPO impact, said Ted Egan, the city’s chief economist. “We’re waiting to see what Uber’s S-1 says before we can take a stab at it, because Uber is the one that will make the most difference in overall revenue,” he said, referring to the initial disclosure filing companies make in going public. Still, one crucial variable will remain unknown: What will the stock price be when insiders exercise their stock options and sell shares?

The IPO season has already kicked off with Lyft’s premiere last month and Uber’s confidential filing for a premiere expected this month that could value it at $120 billion — the biggest in the U.S. tech world in years. The state’s cut will take a while to materialize. Most companies impose a six-month lockup period before insiders can sell stock or can exercise their stock options — and many may wait longer.

And there’s no guarantee they’ll have a receptive market when they want to sell. Lyft’s stock, for instance, has already tumbled. “A young company still finding its way will be much more volatile than the market as a whole,” Williams said.

There’s a handy analogy: California realized about $1.3 billion over several years from Facebook’s IPO, much of it from CEO Mark Zuckerberg’s staggering tax bill. Although individual taxpayers’ bills are private, Facebook disclosed Zuckerberg’s exercises of stock options and sales of shares, making much of his income public record.

That May 2012 debut valued Facebook at $104 billion, the largest ever for a newly public company. Before Facebook went public, the state expected to reap $2.1 billion, projecting that the stock price would rise during the six-month lockup period. Instead it fell.

Zuckerberg’s well-publicized tax bill and California’s super-high income tax rate may spook some people standing to gain big wealth from IPOs, said Christopher Thornberg, principal of Beacon Economics. His hunch: Folks who invested in Uber and other companies going public “have been tax planning for a while to minimize their obligations to the state.” A smattering of millionaires have fled the state since it increased its income tax in 2012, one study shows.

“When you see a giant tax bill on the horizon, you’re willing to spend a lot of money on tax attorneys and expensive homes to dodge as much as possible,” he said. “On the other side, the state will make sure it gets every penny it’s entitled to.”

California’s history with stock-market riches is far from illustrious. During the dot-com days when the state was flooded with tech money, it embarked on a spending orgy, certain the good times would last. They didn’t. California was saddled with huge fiscal commitments, such as pension obligations, and no way to pay the tab. It ended up in a hole — and Gov. Gray Davis got recalled.

“The dot-com boom went spectacularly bust,” said Palmer from the state finance department. “One-time revenues disappeared, yet we had a higher base of ongoing state spending that created in short order multibillion-dollar deficits.”

The state was still awash in red ink when the 2007-2009 recession hit. But since then the budget has been balanced and California has new safeguards in place — notably the rainy-day fund, officially called “the budget stabilization account.”

“We take those one-time spikes off the table and put them in a protected account that can only be tapped under very specific conditions of economic decline,” Palmer said. “It’s an insurance policy to reduce the severity of the spending cuts in an economic downturn.”

Started in 2014-15 under Gov. Jerry Brown, the rainy-day fund now has $13.5 billion, projected to rise to almost $20 billion by 2022-23. (Projections don’t account for any specific offerings but assume a favorable economic climate this year.) Still, the trick will be to keep lawmakers and interest groups from treating any newfound wealth as a piggy bank for their pet programs.

If the bottom falls out of the stock market and a recession occurs — events that generally happen in tandem — even $20 billion of reserves won’t last long.

“Very quickly capital gains dry up, and they’re such an important part of the revenue base now, that that can have a profound impact on the state,” Williams said.

So far, Gov. Gavin Newsom has won economists’ praise for emphasizing one-time spending and debt repayments.

“Newsom’s budget suggests he’s channeling his inner Jerry Brown and wants to be a fiscal conservative,” Thornberg said. “Hopefully he’ll continue to do something logical, using (windfalls) to fill a hole as opposed to starting new programs that will come back to haunt us when we have the next recession.”

Carolyn Said is a San Francisco Chronicle staff writer. Email: csaid@sfchronicle.com Twitter: @csaid