I pledge allegiance to the flag of the United States of America and to the republic for which it stands, one nation under God, indivisible, with liberty and justice for all. Written in August 1892 by Francis Bellamy (1855-1931). It was published in The Youth's Companion, September 8, 1892. In its original form it read, "I pledge allegiance to my Flag and the Republic for which it stands, one nation, indivisible, with liberty and justice for all."
In 1923, the words, "the Flag of the United States of America" were added against Bellamy's wishes. Congress added "under God" in 1954, creating the 31-word pledge we say today.