Turkish Airlines offers a free tour of Istanbul if your layover time there is between 6 and 24 hours. (If your layover is over 20 hours, there's a different program where they will give you a hotel room in Istanbul. I've done the latter after missing a connection. I recommend it.)
From https://www.turkishairlines.com/en-us/flights/fly-different/touristanbul/
About Touristanbul
If you have a connecting international flight in İstanbul, and a layover between 6 and 24 hours, you can take advantage of our complimentary Touristanbul service to discover İstanbul.
With Touristanbul, you can visit İstanbul’s most notable historical sites and enjoy authentic Turkish cuisine. In the city that never sleeps, Touristanbul offers an unforgettable experience.
If you are on an international flight that connects through İstanbul with a layover between six and 24 hours, the Touristanbul service is provided free of charge. After landing at İstanbul Airport, you will be picked up by a vehicle and driven back to the airport at the end of the tour.
How to book Touristanbul
After your Turkish Airlines connecting international flight lands in İstanbul, you can sign up for Touristanbul at the Hotel Desk in the International Arrivals Terminal of İstanbul Airport. Touristanbul is only available for flights operated by Turkish Airlines. Passengers can take advantage of free tour using their ticket number only ıf issued by Turkish Airlines stock number starting 235.
Before visiting Türkiye, you can obtain an e-visa at www.evisa.gov.tr/ website. Please check your country’s requirements to see if it is necessary to obtain a visa to enter Türkiye.
If you are eligible for an e-visa you may obtain it from the Turkish Airlines Sales / Ticket Desks before or on the day of your departure.
The service for connections over 20 hours obviously doesn't apply to you, but for other readers who might be interested, it is described at https://www.turkishairlines.com/en-us/flights/stopover/