At SJU, stay airside—compact terminal with dining and shops makes staying inside easiest.
A 3-6 hour layover at SJU is very doable. Grab an airport taxi ($15-20) to Old San Juan - the 15-minute ride drops you at the city walls. Walk the blue cobblestone streets, see El Morro fort from the outside (the grounds are free, interior costs $10), and grab a mofongo from a restaurant on Fortaleza Street. Head back 75 minutes before your flight.
Six to ten hours lets you see Old San Juan properly. Start at El Morro fort and walk the walls to San Cristobal. Walk Fortaleza Street and browse the galleries and shops. La Bombonera on San Francisco Street has been serving mallorcas (sweet pastries) and cafe con leche since 1902. Stop for lunch at any of the mofongo spots on Calle del Cristo. Walk down to the harbor and the Paseo de la Princesa for views. Condado beach (15 min from Old San Juan) is worth adding if you want sand and water. Leave 90 minutes before your flight.
With 10+ hours, add Condado or Santurce to your Old San Juan circuit. La Placita de Santurce is a popular square with market stalls, bars, and street food that fills up on weekend evenings. The Museum of Art of Puerto Rico in Santurce is excellent and free on Sundays. Pinones, east of the airport, has roadside kiosks selling fresh coconut drinks, alcapurrias (fried stuffed fritters), and bacalaitos (salt cod fritters) right by the ocean - a very local experience. Bacardi Rum Distillery offers tours (30 min from airport) for rum history and tasting.