For heaven's sake, you do not need to sleep in the airport or at an airport hotel!
The buses run practically 24 hours a day (check
www.mta.nyc.ny.us for details). If you fly out of JFK, the AirTrain runs 24/7, and obviously the subways run 24/7.
Flushing to LGA would be cheaper and more convenient than JFK, so if I were you, I would do that.