The subway system runs 24/7. A single ride is $2. From downtown, you can take the A train to the Howard Beach station. Expect a long trip - an hour or so. From the Howard Beach station, you can board the Airtrain, an automated train that stops at each of JFK's terminals (takes about 15 minutes). The Airtrain costs $5 for transport between the terminals and Howard Beach Station or Jamaica Station. Budget a lot of extra time to make it to the airport. I haven't taken that route in a while, so my estimates may be off.