Are you a US resident or a nonresident for tax purposes?
You are a US resident for tax purposes if you are a US citizen, hold a green card, or meet the substantial presence test (physically present at least 31 days in the current year and 183 days under a weighted three-year formula). Residents are taxed on worldwide income; everyone else is a nonresident alien taxed only on US-source income.
The weighted formula counts all of the current year’s days, one third of last year’s days, and one sixth of the days from the year before that. Even if it adds to 183 or more, a closer connection exception (Form 8840) or a tax treaty tie-breaker can preserve nonresident status when your real home and ties remain abroad.
Some people are "exempt individuals" whose US days do not count at all: foreign students on F-1 visas for their first five years, and teachers and trainees on J visas for two years, among others. They file Form 8843 to document the status and often remain nonresidents far longer than their day count alone would suggest.