In a medium saucepan, combine water and sugar. Stir until sugar is dissolved.
Add cinnamon sticks, whole cloves, allspice berries, and star anise to the saucepan.
Bring the mixture to a simmer over medium heat. Reduce heat to low and let it simmer gently for 10-15 minutes, allowing the spices to infuse.
Remove the saucepan from the heat. Stir in the vanilla extract.
Let the syrup steep for another 10-15 minutes, or until it reaches your desired flavor strength.
Strain the syrup through a fine-mesh sieve into a clean jar or bottle, discarding the spices.
Let the syrup cool completely before sealing and storing in the refrigerator.
Notes
This syrup is best stored in the refrigerator and will last for about 2-3 weeks. It's perfect for cocktails, hot beverages like coffee and tea, or drizzled over pancakes and waffles.