I’ve actually had ants in my own laptop before so I totally get how stressful and gross it feels. Don’t panic—ants are annoying but you can get rid of them without destroying your device.
Here’s what worked for me:
First I shut down my laptop, unplugged it, and removed the battery. This prevents short circuits.
Next I took it outside, gently shook it upside down and at angles. I used short bursts of compressed air around the keyboard, vents, and ports. Many ants came out this way.
Then I wiped the exterior with a cloth dampened with water and white vinegar—helps remove scent trails. Avoid letting liquid inside.
If there are a lot of ants or a suspected nest, open the laptop. If comfortable, unscrew the back and clean with a brush and compressed air. Otherwise, take it to a repair shop.
Finally I reassembled and powered it up. It worked fine, but if you notice issues, get it checked professionally.