"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."
The first Pledge of Allegiance was written in 1885 by Captain George Thatcher Balch, a Union Army officer in the Civil War. This early version of the pledge stated, "We give our heads and our hearts to God and our country; one country, one language, one flag." While it gained some popularity among the ranks of the military it was still relatively unknown to most of the public.
A modified version of the Balch pledge was produced in 1892 by Francis Bellamy. Hoping that he had made a pledge that could be used by many different nations, this version was short and generic. Bellamy's pledge, "I pledge allegiance to my Flag and the Republic for which it stands, one nation, indivisible, with liberty and justice for all.", would later form the basis for the official pledge adopted by Congress.
As the popularity of the pledge began to increase across the country, immigration into the United States was also increasing. At some point a concern arose over immigrants that might gain citizenship here while retaining allegiance to the country from which they originated. So, in 1923, the National Flag Conference called for the pledge to be modified again. This change added the words "the Flag of the United States of America" to the pledge.
Then, on June 22 of 1942, the United States Congress officially recognized the pledge for the first time. The official name, The Pledge of Allegiance, was adopted in 1945. A few years later, President Eisenhower signed a law that added the words "under God," to the pledge.
Finally, on Flag Day (June 14) in 1954, we arrived at the official pledge as we know it today: "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."
Federal Law regarding the U.S. Pledge Of Allegiance
4 U.S. Code § 4 - Pledge Of Allegiance To The Flag; Manner Of Delivery
The Pledge of Allegiance to the Flag: "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.", should be rendered by standing at attention facing the flag with the right hand over the heart. When not in uniform men should remove any non-religious headdress with their right hand and hold it at the left shoulder, the hand being over the heart. Persons in uniform should remain silent, face the flag, and render the military salute. Members of the Armed Forces not in uniform and veterans may render the military salute in the manner provided for persons in uniform.