First up, you should look at the Port Authority of New York and New Jersey page on hotels at JFK, which lists the closest hotels to the airport. There are a few ones a little further out that you can consider too.
Most of the hotel shuttles leave from by the rental car area, accessible by the AirTrain. Some just turn up on schedule, others you need to ring and they'll send the bus. There's a number of decent hotels within a 10 minute shuttle bus ride of the airport. Some even with good onward connections to the city if you want to spend a few hours there the next morning, or even just with some decent places to go for lunch.
For an airport hotel, in a big city, turning up around midnight is fine. They might have closed the bar, they probably won't be doing much/any food, but they'll be open and will be expecting checkins.
However... You should let them know that you'll be arriving late. Otherwise, there's always a chance that they'll think you're not coming and re-sell your room if they're full. Drop the hotel a call / email the day before, and let them know the late arrival time, and they'll make a note plus be sure to hold the room for you.
I'd suggest you do a search on your favourite hotel booking site, for hotels around JFK, and get a shortlist. Next, go to the hotel's own website (don't trust third party ones here!), and verify if the hotel has a shuttle service from the airport, and how often it is. Pick one that look OK, is in your price range, and has a quick shuttle bus ride that's frequent or on-demand, and book.
You might also want to double check with something like TripAdvisor, or on FlyerTalk. There's a few with terrible reputations, which often seem to change name/branding, which should be avoided. I don't think there are any "amazing" hotels, but then it's by an airport a way out of the city. There are several solid, decent hotels there. My "decent and a fair price" might not be the same as yours though, so I won't mention any, you need to research against your own criteria then check recent reviews!
Make a note of the phone number and the address of the hotel, especially if you're staying with a chain. You don't want to find yourself at the wrong Holiday Inn / Residency Inn / Comfort Inn / Hampton etc, at airports where there is more than one!