Born and raised in Florence, Viviani studied at a Jesuit school. There, Grand Duke Ferdinando II de' Medici furnished him a scholarship to purchase mathematical books. He became a pupil of Evangelista Torricelli and worked on physics and geometry.
In 1639, at the age of 17, he was an assistant of Galileo Galilei in Arcetri. He remained a disciple until Galileo's death in 1642. From 1655 to 1656, Viviani edited the first edition of Galileo's collected works.
After Torricelli's 1647 death, Viviani was appointed to fill his position at the Accademia dell'Arte del Disegno in Florence. Viviani was also one of the first members of the Grand Duke's experimental academy, the Accademia del Cimento, when it was created a decade later.
In 1660, Viviani and Giovanni Alfonso Borelli conducted an experiment to determine the speed of sound. Timing the difference between the seeing the flash and hearing the sound of a cannon shot at a distance, they calculated a value of 350 meters per second (m/s), considerably better than the previous value of 478 m/s obtained by Pierre Gassendi. The currently accepted value is 331.29 m/s at 0 °C or 340.29 m/s at sea level. It has also been claimed that in 1661 he experimented with the rotation of pendulums, 190 years before the famous demonstration by Foucault.
By 1666, Viviani started to receive many job offers as his reputation as a mathematician grew. That same year, Louis XIV of France offered him a position at the Académie Royale and John II Casimir of Poland offered Viviani a post as his astronomer. Fearful of losing Viviani, the Grand Duke appointed him court mathematician. Viviani accepted this post and turned down his other offers.
In 1687, he published a book on engineering, Discorso intorno al difendersi da' riempimenti e dalle corrosione de' fiumi.
In 1737, the Church finally allowed Galileo to be reburied in a grave with an elaborate monument. The monument that was created in the church of Santa Croce was constructed with the help of funds left by Viviani for that specific purpose. Viviani's own remains were moved to Galileo's new grave as well.