T4 has the Central Diner in the arrivals area near the taxi stand and it's open 24 hours. The reviews of the food, unfortunately, aren't so good but I'm sure it's still a decent place to relax and be waited on. Not sure where you're from but a good rule for diners is to just order eggs if you're worried about food quality. Here's a link:
http://www.yelp.com/biz/central-diner-jamaica
Another option might be the pre-security food court in T1 - on the second level balcony above ticketing. A blog recently reported that there is a dunkin donuts cart there that is open 24 hours:
http://blog.sleepinginairports.net/2.../#.VRv38PnF-Ig
The blog post above also notes that there are pax trying to sleep at T5 landside and it gives a good description of the area. As others have noted T5 has free wifi provided by JetBlue, unlike other JFK terminals.
I can't figure out what time T5 airside / post-security closes and re-opens, but as the last poster mentioned you won't be allowed back through security until it has re-opened. My best guess would be that it re-opens around 4am.