At PEK or PKX, stay airside—both airports are huge with long security and transfer distances, so use lounges, dining, and stay near your gate.
With TWOV status, take the Airport Express from PEK to Dongzhimen (16 min, CNY 25), then Metro Line 2 two stops to Gulou Dajie for Houhai Lake and Nanluoguxiang hutong area. Total commute: 35 to 40 minutes each way. You have roughly 60 to 90 minutes in the area before heading back. Skip any site that requires a ticket purchase or long queue. If departing from PKX, the extra 20 minutes of transit makes a 3 to 6 hour exit very tight.
Nanluoguxiang hutong is 40 minutes from PEK by rail: Airport Express to Dongzhimen, then Metro Line 2 to Beixinqiao. The alley has good cafes, street food, and a walkable historic atmosphere. Budget CNY 60 to 80 ($9 to $11) for a sit-down meal nearby. Wangfujing shopping street is one Metro stop from Tiananmen East and takes 50 minutes total from PEK.
Tiananmen Square (exterior, free) and the Temple of Heaven park (CNY 15, about 30 min from central Beijing by Metro Line 5) are the best bets for a long layover. The Tiananmen area to Temple of Heaven circuit takes 3 to 4 hours. Add Wangfujing for lunch at one of the street-food side lanes.