The data considered covers only actions of the US Federal Government from its founding.
Max of 8 was in 1918. 40 out of the 246 years between 1775 and 2017 had zero active wars (16.26% of US history are peaceful years). Longest consecutive period of peace was 6 years, and happened twice: 1934-40, and 1976-81.
Prior to 1900, all but the Revolutionary War, Mexican-American War, and Civil War were against native tribes.
The longest war in US history is against the Apache Nation, which was continuous from 1849-1925: 77 years, seen here as an extreme outlier. It was the last of the American Indian Wars, immediately following the Last Indian Uprising 1923-24.
Red areas correspond to lands apportioned via treaty from tribes listed as being in a war, circa 1894-1897
Yellow areas correspond to current Indian reservations, 2020 Census
Prior to 1900, all but the Revolutionary War, Mexican-American War, and Civil War were against native tribes.