A TERRIFYING mini-stroke scared TV JUDGE JUDY SHEINDLIN into com­pletely turning her life around – and she now follows a strict diet and exercise program.

The tough-talking 71-year-old made the drastic lifestyle changes after she was rushed to the hospital with a TIA – a transient ischemic attack – three years ago. Docs warn that a TIA can either be a harbinger of doom for a more serious stroke or just a warning to take steps to prevent one. Judy seized the opportunity to change her ways – and it seems to have worked.

The New York native is in the middle of her 18th season of her syndicated “Judge Judy” show and will continue to film the hit series until at least through 2017.

“The TIA terrified her,” said a source. “She knew she was in danger of suffering a full-blown stroke if she didn’t start taking better care of herself, so she sought help from a doctor and a trainer to keep her alive.”

Today, the judge, who’s extra busy with her new show, “Hot Bench,” and a one-hour CBS special, “Judge Judy Primetime,” is in tip-top shape. In fact, she even posted a shot of herself in a white bikini while vacation­ing in The Exumas.

Judy’s life was thrown into a tailspin in March 2011 when she became confused and disorient­ed during the taping her show at KTLA Studios in Los Angeles.

“That day, I was pretty focused on the case I was working on,” she said. “I was asking questions, but I was talking in slow motion.

“The people who watched me for 15 years noticed something was wrong, and then without asking me – which was good since I probably would have said, ‘Don’t go there’ – called the paramedics.”

Although she made a full recovery, the TIA served as a wake-up call.

“She realized she needed to start taking better care of herself if she wanted to be around for her husband, their five children and 12 grandkids, not to mention her millions of fans,” said a close friend.

Judy’s new way of life in­cludes cutting back on portions and only eating two meals a day with a few small, healthy snacks in between.

“Judy basically eats a meal late morning and another one before 6 p.m.,” said the pal. “And she sticks to a low-fat diet with no fried chicken, pasta, starchy mashed potatoes and gooey deserts. She also eliminated most dairy products, and takes the drug Plavix to prevent getting blood clots.”

Instead, the source says Judy eats a salad with some grilled chicken or a tuna sandwich with to­mato on whole grain toast for lunch. For dinner she may have salmon, a small baked potato and some low-fat Greek yogurt or quinoa. And she snacks on fresh fruit, raw baby carrots and low-fat microwave popcorn.

The judge – who reportedly makes a whopping $47 million a year – also amped up her workout routine by walking three miles a day, lifting weights and doing lots of stretching.

“Judy has no plans to retire,” the pal added. “She feels the best she’s felt in years."