A marriage may go bad. But you can at least have a good divorce.

For proof, just look at MacKenzie Bezos. The ex-wife of Jeff Bezos has emerged from her split with the Amazon founder not only as the fourth-richest woman in the world but also possibly the most gracious woman in the universe.

She tweeted on April 4, “Grateful to having finished the process of dissolving my marriage with Jeff with support from each other and everyone who reached out to us in kindness, and looking forward to next phase as co-parents and friends.”

She went on to say that she’d be giving him all of her interests in The Washington Post and Blue Origin, as well as 75 percent of her Amazon stock and voting control of her shares. She then declared that she was “excited about my own plans. Grateful for the past as I look forward to what comes next.”

In an age where social media has made it possible for everyone to air their dirty laundry with the click of a button — and possibly parlay their anger into a book deal or TV show — keeping private matters private seems almost quaint.

When a Kardashian gets cheated on, she’ll fire off an all-caps response on social media declaring, “You ARE the reason my family broke up!” as Khloe did to Jordyn Woods, her partner’s paramour.

Christina Anstead and Tarek El Moussa, the formerly married stars of “Flip or Flop,” leveraged their split into new franchises (“Christina on the Coast” and a yet-unnamed solo show for Tarek to premiere on HGTV).

Meanwhile, Taylor Swift has turned practically every breakup into an attention-grabbing song.

Turning your heartbreak into a profit grab has become one of the crasser examples of capitalist American culture.

Which makes MacKenzie’s graciousness something of a refreshing surprise. Bezos’ ex certainly had as much reason to feel angry as anyone. After all, her husband cheated on her with their neighbor, the bodacious Lauren Sanchez, and did so in a way that made him ripe for ridicule, with leaked texts referring to his married lover as “alive girl” — a phrase so strange and funny it became an instant meme.

Infidelity after 25 years of marriage would be infuriating enough. But MacKenzie was also instrumental in founding Amazon. She was one of the company’s first employees. According to Business Insider, she negotiated the first freight contracts for the company. The couple had no prenup and if she had wanted to, she could have fought for half his fortune and embarrassed the hell out of him in court.

At the very least, MacKenzie could have said something clever and mean about her ex in this situation. Remember Nicole Kidman quipping “I can finally wear heels again” after her divorce from Tom Cruise? MacKenzie could have made a crack like that, and we wouldn’t have held it against her.

But she’s chosen not to. In fact, she’s not been seen or heard from since the divorce was announced.

And the only reason for that can be she is a woman of tremendous restraint and good taste. She must also be the kind of mother who wants to protect her four children from the horrors of a public divorce.

In this, she’s something of an anomaly. While you would think that a few billion dollars could soften heartbreak — and it’s estimated that MacKenzie walked away from the divorce with $36 billion — that’s not always the case.

Big money often seems to make for even bigger, splashier and more horrifying splits.

Just look at billionaire real-estate mogul Harry Macklowe, who in March plastered a 42-foot banner of himself and his new wife on a building in which his ex-wife was buying an apartment. Maybe this prompted some laughs from friends of Macklowe’s, but to anyone who doesn’t know him, it’s just a reminder that money can’t buy class.

Last year, when the billionaires Sue and Bill Gross divorced, Page Six reported that Sue had swapped a Picasso they owned with a replica so as to take the original. Meanwhile, Bill put dead fish in their home’s air ducts to stink it up before Sue took it in the divorce.

MacKenzie can move on to new projects and new relationships with her head held high, knowing that she behaved with a level of dignity that’s rarely seen today.

And, while she may have been generous with him financially, Jeff Bezos is hopefully smart enough to know how much he’s lost.