The term “aliens” is used to categorize people who are not the citizens of the US, and nonresident aliens are those who are temporarily in the country as they did not pass the green card or any other substantial presence tests.
People from foreign countries or foreign nationals who reside in the US and earn within the country have to pay taxes on the income. To determine the tax rate easily, the IRS has separated the foreign nationals into resident and nonresident aliens.
Resident aliens are the citizens of the US or foreign people living in the country who have qualified wither the green card test or a substantial presence test. Generally, people with F and J visas are considered resident aliens after completing five calendar years in the country.
H-1, TN, and O-1 visa holders become resident aliens after completing the substantial presence test requirements. Researchers and professors on a J visa are also considered resident aliens after completing two calendar years.
A nonresident alien does not meet the requirements to be categorized as a US citizen and has not passed the green card or substantial presence test. IRS has taken out a rule of thumb to determine and classify nonresident aliens. If the person has been in the US for less than 31 days in one year or less than 183 days within three years, they qualify for taxes as a nonresident alien.
The situation for a nonresident alien is a bit different when they are married to a US citizen, where the spouses file for taxes together under the Form 1040, and the filing status is “Married Filing Jointly.”
Nonresident aliens are those who have a company or trade in the US. Even if you don't operate a company in the US but are making money there, you must register as a nonresident alien for all untaxed income.
For a nonresident alien, two different types of income must be reported while filing the taxes. One is the income from a business or trade in the US or is “Effectively Connected” to a business or trade. The other is the US sources of income that is Fixed, Determinable, Annual, or Periodical (FDAP).