Born in 1615 in Dublin to Sir John Denham, who was one of the Barons of the Exchequer, and his second wife, Eleanor Moore, he was taken to England within two years. The location of his early schooling is uncertain, but he was enrolled at Trinity College, Oxford, by November 1631, and in his Athenae Oxonienses (1691-1692)
From Oxford he proceeded to the study of law at Lincoln's Inn in London, and he was admitted to the bar in 1639. Meantime he had married Anne Cotton on 25 June 1634, and his father had died on 6 January 1639, leaving him a considerable estate. Three years later The Sophy, Denham's first publication, prompted Edmund Waller's euphoric observation that the author of this tragedy, "admired by all ingenious men, ... broke out like the Irish Rebellion, threescore thousand strong, when no body was aware, or in the least suspected it."
The outbreak of open war between Charles I and the Parliament prevented Denham's pursuit of either legal or literary ambitions. In 1642 he published Cooper's Hill, destined to be his best-known poem, but by October of that year, as High Sheriff for Surrey and Governor of Farnham Castle, he had taken up arms for the Royalists, and by December he became a prisoner of war in London for a brief period. He was imprisoned again on 23 January 1646; but, on orders issued directly by the House of Commons, he was exchanged for a certain Major Harris who was held prisoner by the Royalists. Apparently he was never a major figure in the King's cause, but he was a devoted and faithful one, whether engaged in the siege of Dartmouth (January 1646) or the battle for Exeter (April 1646), in France in the company of Queen Henrietta Maria for nearly a year (from May 1646 to March 1647), in London as informant (1647-1648), or in Poland from 1649 to 1651 by Charles's appointment to raise money (ultimately more than £10,000) from the King's Scottish subjects in that country. Even though his estates were confiscated, his friendship with the Earl of Pembroke helped him avoid total devastation in those darkest days. With the Restoration of the monarchy in 1660 his fortunes improved.
He succeeded Inigo Jones (and preceded Christopher Wren) as Surveyor of the Works; and, although not a few complained that he lacked the necessary architectural skills, he was responsible for overseeing the construction of Burlington House and Greenwich Palace and for considerable improvements in the paving of the London streets. Other and even more significant honors followed. At the coronation of Charles II Denham was made Knight of the Bath, and he was named "Clerk of the Works in the Tower of London and in all his majesty's honors, castles, etc. reserved for his abode." In April 1661 he was returned to Parliament from Old Sarum, County Wilts, and in May 1663 he was elected a member of the Royal Society. The prosperity of his final years was marred, however, by domestic and physical difficulties. His first wife had died sometime between 1643 and 1647; his second wife, Margaret Brooke, whom he married on 25 May 1665, was almost thirty years his junior and became notorious in 1665 as the Duke of York's mistress. Rumor blamed his brief period of madness in the following year, probably occasioned by paresis, on the embarrassment and indignation occasioned by his cuckoldry. His wife's mysterious death in 1668 prompted additional rumors, but an autopsy revealed no trace of poison.
His sanity restored, Denham returned to Parliament and to his duties as Surveyor of the Works during his final years, dying in his office, probably of apoplexy, on 10 March 1669, with burial following in the Poets' Corner of Westminster Abbey.
Denham's poetic work, especially Cooper's Hill contributed directly to his contemporary popularity; certainly it was the major reason that his literary reputation remained relatively high throughout the eighteenth century. His light verse includes personal, religious, political, and poetical satire; and he translated a considerable body of material from the French, Greek, and Latin--including act five of Corneille's Horace. But it was the "local poem," Cooper's Hill , printed at least twenty-four times between 1642 and 1826, in addition to nineteen collected editions of his poetry by 1857, that secured his fame for fully a century and a half. He directly influenced such work as Waller's Poem on St. James's Park, Dyer's Grongar Hill, and Pope's Windsor Forest; and Dryden considered him a significant poetic voice that was instrumental in popularizing the closed couplet. Sir John Denham, in a word, was a poet, playwright, courtier, and wit renowned in his own and succeeding generations. Among the last plays written before the closing of the theaters, The Sophy, even if it never realized the production claimed on its title page, brought a measure of contemporary fame to its author that ironically for our age has faded to virtual indistinction.