This question haunts me. I've been asking people, reading forums, reading immigration websites, and I still can't give a clean answer because the law is genuinely complicated here and the stakes are high.
Here's what I understand, with the big caveats up front: I am not a lawyer, this is not legal advice, and H1B rules are enforced inconsistently and change periodically.
The basic rule: H1B authorizes you to work for a specific petitioning employer only. Working for a second employer -- even part-time -- requires a separate H1B petition from that employer.
Where side projects get murky:
If your side project is a hobby/portfolio project with no income, most people I've talked to (including an immigration attorney I consulted) say this is generally fine. You are not 'working' for anyone.
If your side project generates passive income (ad revenue on a blog, royalties from something you built before your H1B) -- also generally considered okay, though I've seen conflicting takes.
If your side project is actively generating income from services or SaaS revenue, you are likely in grey-to-red territory. The concern is 'unauthorized employment,' even if you own the entity. USCIS's position is that if you're doing paid work, even for yourself, that's employment.
Some people structure this as an LLC where a family member (who is a US citizen or GC holder) is the legal owner/employee and you are not compensating yourself. I've heard of people doing this. I won't tell you it's fine because I genuinely don't know and you shouldn't take my word for it.
What I actually did: I paid for a 45-minute consult with an immigration attorney who focuses on tech. Cost me $250. She gave me specific guidance for my specific situation (asset-light SaaS, no employees, income from non-US customers). Worth every dollar.
The general consensus from multiple sources: open-source, no income -- fine. Active paid consulting or services for US-based clients -- real risk. SaaS with passive subscription revenue -- genuinely debated, get legal advice specific to your situation.
If you're on H1B and building something on the side, please don't just crowdsource this on a forum. Get actual counsel. The cost is $200-500; the downside of getting it wrong is your immigration status.