How the substantial presence test works
If you are not a US citizen and do not have a green card, you are a resident alien for tax purposes in a year when you were in the US on at least 31 days that year and at least 183 days over three years, counting:
- all the days in the current year,
- 1/3 of the days in the year before,
- 1/6 of the days two years before.
Example: 120 days in each of 2024, 2025 and 2026 count as 120 + 40 + 20 = 180 days, fewer than 183, so that person is a nonresident for 2026.
Days that do not count
- Days as an exempt individual: students on F, J, M or Q visas, and teachers or trainees on J or Q visas, who comply with their visa (plus certain diplomats, international organization staff and athletes at charity events).
- Days commuting to work from a home in Canada or Mexico, if you commute regularly.
- Days in transit between two places outside the US, for less than 24 hours.
- Days as a crew member of a foreign vessel.
- Days you could not leave because of a medical condition that started in the US.
To exclude exempt or medical days you generally must file Form 8843.
How long are students and researchers exempt?
Students (F, J, M, Q) are exempt individuals unless they have been exempt for any part of more than 5 calendar years. Any part of a year counts as a full year, so a student who arrives in late December has used one of the 5 years. After that, a student can stay exempt only by showing the IRS they do not intend to live in the US permanently.
| First year in the US as a student | Exempt years | Days start counting |
|---|---|---|
| 2026 | 2026–2030 | 2031 |
| 2025 | 2025–2029 | 2030 |
| 2024 | 2024–2028 | 2029 |
| 2023 | 2023–2027 | 2028 |
| 2022 | 2022–2026 | 2027 |
Teachers, researchers and trainees on J or Q visas are not exempt in a year if they were exempt (as a teacher, trainee or student) for any part of 2 of the 6 previous calendar years. For someone who arrives on a J-1 and stays, that usually means two exempt calendar years. A narrow exception applies when a foreign employer pays all their compensation.
Social Security and Medicare for F-1, J-1 and M-1
Nonresident aliens in F-1, J-1, M-1 status are exempt from Social Security and Medicare (FICA) on wages for work their status allows: on-campus jobs (up to 20 hours a week in term, 40 in vacations), off-campus work USCIS authorizes, and practical training such as OPT and CPT. The exemption does not cover F-2, J-2 or M-2 dependents, and it ends when you become a resident alien or change to another status such as H-1B. If FICA was withheld by mistake, ask your employer for a refund first; if you cannot get it, file Form 843 with Form 8316.
What changes when you become a resident alien?
You file Form 1040 instead of Form 1040-NR and report your worldwide income, and Social Security and Medicare apply to your wages. The first year can be a dual-status year, and a tax treaty can change the result in some cases. Our take-home pay calculator and income tax calculator use resident tax rules, so they fit once you are a resident alien.
Sources: IRS, Substantial presence test; IRS, Exempt individual: who is a student; IRS, Exempt individuals: teachers and trainees; IRS, Foreign student liability for Social Security and Medicare taxes.