Johnson was born on Salisbury Plantation near current-day Midlothian in Chesterfield County, Virginia, but his family soon moved to Kentucky. He attended the United States Military Academy and graduated (after five years of study) in 1838. He was commissioned a brevet second lieutenant in the 6th U.S. Infantry and was promoted to first lieutenant in less than a year. He served in the Seminole Wars in Florida and then in the West. In the Mexican–American War, Johnson distinguished himself for action at Veracruz, Cerro Gordo, Churubusco, Molino del Rey, and Chapultepec. He received two brevet promotions, to captain and major, during the war and was awarded a ceremonial sword by the state of Virginia for his bravery. Johnson returned to duty on the Western frontier, serving in the Dakota Territory, California, Kansas, and on the Utah Expedition.