A lot of ins, a lot of outs, a lot of what-have-you's involved with this. See www.irs.gov for more info, or IRS Publication 519, U.S. Tax Guide for Aliens.
Even if you are not a U.S. citizen, you may be required to pay taxes
in the United States. Whether or not you must file a U.S. tax return
depends upon whether the U.S. government considers you a "tax
resident." All permanent residents (green card holders) are tax
residents, but only some holders of nonimmigrant visas are tax
residents. Still, filing a tax return can be a good thing if you've
been working for an employer who's been withholding taxes from your
paycheck -- you may get a refund!
The basic rule for nonimmigrant visa holders is if you spend more than 31 days of the current year AND have spent a total of 183 or more days in the US in the last 3 years, you are considered a "tax resident" and are required to pay taxes.
However, the 183 days isn't really 183 days.
You count 1/3 of the days you were present in the first year before the current year, and 1/6 of the days you were present in the second year before the current year.
So if you spent 50 days in 2013, 25 days in 2014, and 120 days in 2015.. your total days would be 50/6 + 25/3 + 120 = 8.33 + 8.33 + 120 = 136 days, plenty of time to spare. So really unless you have spent a lot of time in the US in the last couple years, the only year you really have to worry about is the current one.
You are considered in the US if you spend any amount of time in a day in the US.
days you regularly commute to work in the Untied States from Canada or Mexico
days you are in the United States for less than 24 hours while travelling
days you are unable to leave the United States because of a medical condition that develops while you are in the country
days you are an exempt individual--for example, you're a student temporarily present in the United States under an "F, " "J, " "M, " or "Q " visa; a teacher or trainee temporarily present under a "J " or "Q " visa; or a diplomat, foreign government employee, or someone otherwise related to a foreign government.
If you exclude days of presence in the United States because you fall into a special category, you must file a fully completed IRS Form 8843, Statement for Exempt Individuals and Individuals with a Medical Condition.
Also, if you meet ALL of the following conditions, you are exempt from paying taxes in the US while on a nonimmigrant visa...
are present in the United States for less than 183 days during the current year
have not applied for a green card
have a closer connection with a foreign country than with the U.S., and
maintain a tax home in this foreign country during the year.
You will be considered to have a closer connection to a foreign country than the United States if you or the IRS establishes that you
have maintained more significant contacts with the foreign country
than with the United States.
There are other exceptions to these tax rules based on tax treaties between the U.S. and your home country.
To avoid double taxation, tax residents may claim a foreign tax credit for income tax paid or owed to a foreign country on foreign source income. To claim the credit, you must file Form 1116, Foreign Tax Credit (Individual, Estate, or Trust), with your Form 1040. For more information, get Publication 514, Foreign Tax Credit for Individuals.
Remote Work Abroad while living on Visa in US
Tax residents must report their entire worldwide income to the U.S. Internal Revenue Service (IRS). It doesn't matter if a portion or all of that income was earned from investments or business activities carried on outside the United States; a tax resident must report it all. But becoming a tax resident does not necessarily mean that the U.S. government will tax all of your worldwide income.
These rules are complicated and subject to a number of confusing exceptions. If you are unsure of your situation, consult a tax accountant or lawyer. Also see IRS Publication 519, U.S. Tax Guide for Aliens, available at www.irs.gov.
If you have a nonimmigrant visa, failure to follow U.S. tax laws can lead to criminal punishment, revocation of your visa, and deportation. Failure to comply with U.S. tax laws can also make it more difficult for you to obtain permanent residency (a "green card") should you ever want it.