2 Samuel 22 is the twenty-second chapter in the second parts of the Books of Samuel in the Hebrew Bible (or the 22nd chapter of the "Second Book of Samuel" in the Old Testament of the Christian Bible). According to Jewish tradition the book was attributed to the prophet Samuel, with additions by the prophets Gad and Nathan, but modern scholars view it as a composition of a number of independent texts of various ages from c. 630–540 BCE. This chapter contains a Song of Thanksgiving attributed to King David which corresponds to Psalm 18. It is within a section comprising 2 Samuel 21–24 containing the appendices to the Books of Samuel.