He was the youngest son of Johann Ambrosius Bach, a town musician, from whom he probably learned the violin and the rudiments of musical theory. When he was ten he was orphaned and went to live with his elder brother Johann Christoph, organist at St. Michael's Church, Ohrdruf, who gave him lessons in keyboard playing. From 1700 to 1702 he attended St. Michael's School in Lüneburg, where he sang in the church choir and probably came into contact with the organist and composer Georg Böhm. He also visited Hamburg to hear J.A. Reincken at the organ of St. Catherine's Church.
After competing unsuccessfully for an organist's post in Sangerhausen in 1702, Bach spent the spring and summer of 1703 as 'lackey' and violinist at the court of Weimar and then took up the post of organist at the Neukirche in Arnstadt. In June 1707 he moved to St. Blasius, Mühlhausen, and four months later married his cousin Maria Barbara Bach in nearby Dornheim. Bach was appointed organist and chamber musician to the Duke of Saxe-Weimar in 1708, and in the next nine years he became known as a leading organist and composed many of his finest works for the instrument. During this time he fathered seven children, including Wilhelm Friedemann and Carl Philipp Emanuel. When, in 1717, Bach was appointed Kapellmeister at Cöthen, he was at first refused permission to leave Weimar and was allowed to do so only after being held prisoner by the duke for almost a month.
Bach's new employer, Prince Leopold, was a talented musician who loved and understood the art. Since the court was Calvinist, Bach had no chapel duties and instead concentrated on instrumental composition. From this period date his violin concertos and the six "Brandenburg Concertos", as well as numerous sonatas, suites and keyboard works, including several (e.g. the "Inventions" and Book I of the '48') intended for instruction. In 1720 Maria Barbara died while Bach was visiting Karlsbad with the prince; in December of the following year Bach married Anna Magdalena Wilcke, daughter of a court trumpeter at Weissenfels. A week later Prince Leopold also married, and his bride's lack of interest in the arts led to a decline in the support given to music at the Cöthen court. In 1722 Bach entered his candidature for the prestigious post of "Director musices" at Leipzig and Kantor of the Thomasschule there. In April 1723, after the preferred candidates, Telemann and Graupner, had withdrawn, he was offered the post and accepted it.
Bach remained as Thomaskantor in Leipzig for the rest of his life, often in conflict with the authorities, but a happy family man and a proud and caring parent. His duties centered on the Sunday and feastday services at the city's two main churches, and during his early years in Leipzig he composed prodigious quantities of church music, including four or five cantata cycles, the "Magnificat" and the "St. John" and "St. Matthew Passions". He was by this time renowned as a virtuoso organist and in constant demand as a teacher and an expert in organ construction and design. His fame as a composer gradually spread more widely when, from 1726 onwards, he began to bring out published editions of some of his keyboard and organ music.
From about 1729 Bach's interest in composing church music sharply declined, and most of his sacred works after that date, including the "B-Minor Mass" and the "Christmas Oratorio", consist mainly of 'parodies' or arrangements of earlier music. At the same time he took over the direction of the collegium musicum that Telemann had founded in Leipzig in 1702 - a mainly amateur society which gave regular public concerts. For these Bach arranged harpsichord concertos and composed several large-scale cantatas, or serenatas, to impress the Elector of Saxony, by whom he was granted the courtesy title of "Hofcompositeur" in 1736.
Among the 13 children born to Anna Magdalena at Leipzig was Bach's youngest son, Johann Christian, in 1735. In 1744 Bach's second son, Emanuel, was married, and three years later Bach visited the couple and their son (his first grandchild) at Potsdam, where Emanuel was employed as harpsichordist by Frederick the Great. At Potsdam Bach improvised on a theme given to him by the king, and this led to the composition of the "Musical Offering", a compendium of fugue, canon, and sonata based on the royal theme. Contrapuntal artifice predominates in the work of Bach's last decade, during which his membership (from 1747) of Lorenz Mizler's learned Society of Musical Sciences profoundly affected his musical thinking. The Canonic Variations for organ was one of the works Bach presented to the society, and the unfinished "Art of Fugue" may also have been intended for distribution among its members.
Bach's eyesight began to deteriorate during his last year and in March and April 1750 he was twice operated on by the itinerant English oculist John Taylor. The operations and the treatment that followed them may have hastened Bach's death. He took final communion on 22 July and died six days later. On 31 July he was buried at St. John's cemetery. His widow survived him for ten years, dying in poverty in 1760.
Bach's output embraces practically every musical genre of his time except for the dramatic ones of opera and oratorio (his three 'oratorios' being oratorios only in a special sense). He opened up new dimensions in virtually every department of creative work to which he turned, in format, musical quality and technical demands. As was normal at the time, his creative production was mostly bound up with the external factors of his places of work and his employers, but the density and complexity of his music are such that analysts and commentators have uncovered in it layers of religious and numerological significance rarely to be found in the music of other composers. Many of his contemporaries, notably the critic J.A. Scheibe, found his music too involved and lacking in immediate melodic appeal, but his chorale harmonizations and fugal works were soon adopted as models for new generations of musicians. The course of Bach's musical development was undeflected (though not entirely uninfluenced) by the changes in musical style taking place around him. Together with his great contemporary Handel (whom chance prevented his ever meeting), Bach was the last great representative of the Baroque era in an age which was already rejecting the Baroque aesthetic in favor of a new, 'enlightened' one.
No measurable appreciation of his great contribution to the history of music was realized until more than a half-century after his death. Mendelssohn brought Bach to the attention of the musical world of the 19th century with a performance of the "Saint Matthew Passion" in Leipzig in 1829. Many of Bach's works were lost in manuscript; a comparatively small number was published during his lifetime. Despite this great loss, the complete edition, begun in 1850 by the "Bach Gesellschaft," contained forty-seven volumes. A second complete edition was begun in 1954. Bach's works were not given opus numbers. Today they are most commonly referred to by BWV (Bach Werk Verzeichniss) numbers. A more logical thematic catalogue is that by Wolfgang Schmieder, published in 1950. In this catalogue, the numbers are preceded by "S."