Bars are notable for staying open late, but I’m not really familiar with alternatives that might operate similarly. I think many cafés (at least around my area) tend to close a few hours earlier by comparison, which would be my go-to for an alternative otherwise, so what other options are there?
It really depends where you are - some places have a lively late night culture, others not so much.
All night diners, 24 hour fast food places are really the only alternatives here (though you could count movie theatres with late showings, I guess).
But (unless you have personal reasons for not being around alcohol and drinkers), you can totally go to a bar with a vibe you like and just hang out drinking soda. Bonus points if that bar has something cool available aside from just booze (barcades, live music venues, etc.).
If you’re not looking to specifically be around people, you could also just check out some green space outdoors, but keep your wits about you and use your judgement - some places are lovely to chill at 3:00 am, some would be if it wasn’t for the sketchy folks shooting up.
One of my absolute favourites is an arcade bar near me that stays open late. I don’t usually drink there but I’ll go and hang out with mates, get some chips and play some retro arcade. Super chill vibe and people there all seem way more chill than most pubs or bars I’ve been to!
Echoing the outside thing. I love to sit on a deck chatting with friends on a warm summer night. There are some biking trails with minimal street crossings nearby that make for a great late night stress-relief ride with or without a friend. I have met a lot of snowboard/stoner/skater bros late at night on trails. Find an abandoned bridge or other public infrastructure and watch the stars while munching on some 24h takeout.