Article III, Section 3 of the Constitution sets a very high bar for convicting an American for treason. Also, like many aspects of the Constitution, there is debate among Constitutional scholars about the exact meaning of this section. It reads as follows:
Treason against the United States, shall consist only in levying War against them, or in adhering to their Enemies, giving them Aid and Comfort. No Person shall be convicted of Treason unless on the Testimony of two Witnesses to the same overt Act, or on Confession in open Court.
So in short, treason is defined as "levying war" against the United States, or "adhering to their enemies," or "giving aid and comfort" to the enemies of the nation. "Levying war" has generally been held to mean actually fighting against the United States. During the Revolutionary War, however, many Americans had joined the British forces, or sworn an oath to the King, without actually fighting against the Revolutionary cause. This is what the Framers had in mind when they added "adhering to their enemies." "Aid and comfort" may include disseminating propaganda on behalf of, or providing with weapons or war materiel (which was common in the Revolutionary era.)
The word "enemies" has usually been held to mean nations against whom the United States was actually in a state of war or, as in the case of the Civil War, rebellion and taking up arms against the nation with the aim of destroying the Union. This is one reason that only a very few convictions for treason have ever been handed down, as even Cold War-era spies and American citizens who have joined terrorist groups have escaped treason charges. During the US Civil War, some Confederate leaders were accused, (but eventually pardoned) for making war against the United States. Another reason that treason convictions are very rare is that two witnesses to the act of treason are required for conviction. In summary, the definition of treason is fairly narrow—by design. This means that conviction for treason is very difficult and thus very rare in American history.