The owner is whoever holds the copyright, and that depends on how the code was written. In the US, code an employee writes within the scope of the job usually belongs to the employer. Code an independent contractor writes usually belongs to the contractor unless a signed written agreement assigns it to the client, and most client contracts do exactly that. So you can sell or license code you wrote for a client only if your contract leaves the rights with you. Code from an old job is usually off limits. This is general information, not legal advice.
If you do hold the rights, there is now a buyer for idle code. AI labs license real source code and git history to train coding models. The license is non-exclusive, you keep ownership, and you are paid per license.
Who owns code written by an employee?
Usually the employer. Under US copyright law, a work an employee creates within the scope of employment is a work made for hire, and the employer is treated as the author from the start. Writing software is squarely within the scope of most developer jobs, so the code you wrote at work belongs to the company, even if you wrote every line.
Most tech employers go further with an invention or IP assignment agreement signed at hiring. These can reach work done outside office hours if it relates to the company’s business or used its equipment. Read yours before you assume a side project is yours.
There are limits. Some states, including California, restrict how far an employee assignment can reach into work done on your own time, without company equipment or information, that does not relate to the employer’s business. A side project that meets those conditions may well be yours. The details vary by state and by agreement.
Who owns code written by a contractor?
The default runs the other way. An independent contractor is the author and owner of what they write unless a signed written agreement transfers it.
The work made for hire rule applies to contractors only in narrow cases. The work has to be specially commissioned, fall into one of a short list of statutory categories, and be covered by a signed agreement saying it is a work made for hire. Software rarely fits those categories. That is why well drafted development contracts include an assignment clause, where the contractor assigns all rights in the work to the client, often in addition to a work for hire clause.
Without a written assignment, the contractor usually keeps the copyright and the client usually gets an implied license to use what it paid for. That does not make the code free to resell. The client’s license, confidentiality terms and the client’s own data inside the code can all limit what you may do with it.
Can I sell code I wrote for a client?
It depends on the contract. Find the clause on intellectual property, ownership or work product in the contract or statement of work. The common patterns:
| What the contract says | Who usually owns it | Can you license it? |
|---|---|---|
| All work product is assigned to the client | The client | No |
| You keep the IP, the client gets a license | You | Usually, subject to confidentiality terms |
| Carve-out for pre-existing or general-purpose tools | You, for the carved-out parts | Those parts only |
| No written agreement at all | Usually you, with an implied license to the client | Possibly; get advice first |
| You wrote it as an employee | The employer | No |
Even where you own the code, a confidentiality or non-disclosure clause can stop you sharing it. And a repo that mixes client-owned code with your own is usually simpler to leave out.
Can I sell code from my old job?
Usually not. If you wrote it as an employee within the scope of the job, the employer owns it, and a copy on your laptop does not change that. Taking it can also breach your employment agreement or trade secret law.
Code you wrote before you joined, or on your own time outside the employer’s business, may be yours. Check whether your agreement listed prior inventions or claimed anything beyond the job.
Who owns the code in a startup?
Before a company exists, each founder owns what they wrote. Most startups then have founders sign an assignment that moves that code into the company, and investors check for it. After that, the company owns the code, including after it shuts down, unless the assets were sold or transferred to someone else.
So if a startup failed, the code belongs to the company or whoever acquired its assets. Any founder who wants to license it needs the company’s consent, which usually means agreement among the remaining founders or directors. Where code was never assigned and two founders wrote it together, they may be joint owners. In the US, a joint owner can generally grant a non-exclusive license but must share the proceeds with the other owners. For the full situation, see the page on how to sell dead startup code.
What about agencies?
Agencies usually assign client work to the client on payment. Internal tools, starter kits, in-house frameworks and products the agency built on its own account are usually the agency’s. If you run a studio with years of repos, the page our agency has old code walks through what tends to qualify.
What about open source dependencies?
Open source libraries in your repo stay under their own licenses. They are excluded from what is licensed. Your own code and its git history are what count, and having dependencies does not stop you licensing the rest.
Does the law differ outside the US?
Yes. Many countries also give employers the rights in software written by employees, and the EU has a specific rule to that effect for computer programs. Rules for contractors and commissioned work vary more, and some countries recognize moral rights that cannot be signed away. If you or the company were outside the US when the code was written, check the local rules.
How do I check that I hold the rights?
Go repo by repo and gather the evidence:
- Contracts. Employment agreements, contractor agreements, statements of work and any IP or confidentiality clauses.
- Invoices. Who paid for the work, and under which contract.
- Repo history. Commit authors and emails, dates, and which account or organization owned the repo. Commits made with a work email during a job are a warning sign.
- Company records. For a startup, the founder assignment and what happened to the assets at shutdown.
- Third-party content. Vendored libraries, client data and production databases stay out.
If a repo passes, it is yours to license. If it is unclear, leave it out or ask a lawyer.
What can I do with code I own?
License it to AI labs. Labs pay for real, private code with real history, and commercial success makes no difference. You choose the repos, give read-only access, and secrets and personal data are stripped from the review copy before any buyer sees it. You keep ownership, and because the license is non-exclusive, the same repo can earn again.
A typical repo earns about $1,000 to $1,500 per license. Source code pays $100 per million tokens and git history pays $40 per million. For the working, read how much is my code worth. For why labs pay at all, read sell code for AI training.
When you know which repos are yours, get a valuation. You see a real per-repo estimate once you connect Git, and there is no fee and no commitment.