His father, Johann Ambrosius, a musicial director, likely taught him violin and basic music theory. His uncles were all professional musicians, whose posts included church organists, court chamber musicians, and composers. One uncle, Johann Christoph Bach (1645–93), introduced him to the organ, and an older second cousin, Johann Ludwig Bach (1677–1731), was a well-known composer and violinist.
In April 1700, Bach enrolled in the prestigious St. Michael's School in Lüneburg, some two weeks' travel north of Ohrdruf. The journey was probably undertaken mostly on foot. His two years there were critical in exposing Bach to a wider range of European culture. In addition to singing in the choir, he played the School's three-manual organ and harpsichords. He came into contact with sons of aristocrats from northern Germany, sent to the highly selective school to prepare for careers in other disciplines.
In January 1703, shortly after graduating from St. Michael's and being turned down for the post of organist at Sangerhausen, Bach was appointed court musician in the chapel of Duke Johann Ernst III in Weimar. His role there is unclear, but it probably included menial, non-musical duties. During his seven-month tenure at Weimar, his reputation as a keyboardist spread so much that he was invited to inspect the new organ and give the inaugural recital, at the New Church (now Bach Church) in Arnstadt, located about 19 mi southwest of Weimar. In August 1703, he became the organist at the New Church, with light duties, a relatively generous salary, and a fine new organ tuned in a temperament that allowed music written in a wider range of keys to be played.
Despite strong family connections and a musically enthusiastic employer, tension built up between Bach and the authorities after several years in the post. Bach was dissatisfied with the standard of singers in the choir. He called one of them a "Zippel Fagottist" (weenie bassoon player). The conflict was resolved, but Bach was disenchanted with the assignment.
Appointment in Leipzig: After having been offered the position of Thomaskantor in 1722, Bach was invited to Leipzig. Bach was required to instruct the students of the Thomasschule in singing and to provide church music for the main churches in Leipzig. Bach was required to teach Latin, but he was allowed to employ four "prefects" (deputies) to do this instead. The prefects also aided with musical instruction. A cantata was required for the church services on Sundays and additional church holidays during the liturgical year.
Bach usually led performances of his cantatas, most of which were composed within three years of his relocation to Leipzig. The first was Die Elenden sollen essen, BWV 75, performed on 30 May 1723, the first Sunday after Trinity. Bach collected his cantatas in annual cycles. Of the more than three hundred cantatas which Bach composed in Leipzig, over one hundred have been lost to posterity. Most of these concerted works expound on the Gospel readings prescribed for every Sunday and feast day in the Lutheran year. Bach started a second annual cycle the first Sunday after Trinity of 1724 and composed only chorale cantatas, each based on a single church hymn.
Bach broadened his composing and performing beyond the liturgy by taking over, in March 1729, the directorship of the Collegium Musicum, a secular performance ensemble started by Telemann. This was one of the dozens of private societies in the major German-speaking cities that was established by musically active university students; these societies had become increasingly important in public musical life and were typically led by the most prominent professionals in a city. In the words of Christoph Wolff, it "consolidated Bach's firm grip on Leipzig's principal musical institutions". Year round, the Leipzig's Collegium Musicum performed regularly in Leipzig venues. Many of Bach's works during the 1730s and 1740s were written for and performed by the Collegium Musicum; among these were parts of his Clavier-Übung (Keyboard Practice) and many of his violin and keyboard concertos.
To a large extent, Bach's musical style fits in the conventions of his day, which is the final stage of the baroque style. When his contemporaries, such as Handel, Telemann and Vivaldi wrote concertos he did so too. When they wrote suites, he did so too. From an early age, he imbued himself with the compositions of his contemporaries and of prior generations, all of what was available from European composers, such as the French, the Italian, and those from all parts of Germany, and there is little of it that didn't appear in his own music.
Religious music was at the center of Bach's output for much of his life. The hundreds of sacred works he created are usually seen as manifesting not just his craft but a truly devout relationship with God. He had taught Luther's Small Catechism as the Thomaskantor in Leipzig, and some of his pieces represent it. The Lutheran chorale was the basis of much of his work. In elaborating these hymns into his chorale preludes, he wrote more cogent and tightly integrated works than most, even when they were massive and lengthy. The large-scale structure of every major Bach sacred vocal work is evidence of subtle, elaborate planning to create a religiously and musically powerful expression. For example, the St Matthew Passion, like other works of its kind, illustrated the Passion with Bible text reflected in recitatives, arias, choruses, and chorales; but in crafting this work, Bach created an overall experience that has been found over the centuries since to be both musically thrilling and spiritually profound.
Bach published or carefully compiled in manuscript many collections of pieces that explored the range of artistic and technical possibilities inherent in almost every genre of his time except opera.
In January 1749 Bach's daughter Elisabeth Juliane Friederica married his pupil Johann Christoph Altnickol. Bach's health was however declining. On 2 June, Heinrich von Brühl wrote to one of the Leipzig burgomasters to request that his music director, Johann Gottlob Harrer, fill the Thomaskantor and Director musices posts "upon the eventual ... decease of Mr. Bach". Becoming blind, Bach underwent eye surgery, in March 1750, and again in April, from the British eye surgeon John Taylor. Bach died on 28 July 1750, from complications connected to the unsuccessful treatment.
An inventory drawn up a few months after Bach's death, shows that his estate included five harpsichords, two lute-harpsichords, three violins, three violas, two cellos, a viola da gamba, a lute and a spinet, along with 52 "sacred books", including works by Martin Luther and Josephus. The composer's son Carl Philipp Emanuel saw to it that The Art of Fugue, however still unfinished, was published in 1751.