Suppose I download an open source project from GitHub and modify the code further.

Can I patent this code and restrict others to reuse my "modified" code?

2 Answers 2


You can not patent code. You can only patent an invention which is implemented in your code. An invention is a new and unique way of doing something. Most of all, it must be something nobody did before. If anyone used the same technique which you describe in your patent, that's called prior art and invalidates your patent. So trying to get a patent on something somebody else invented and implemented in code would be futile.

But what you could do is try to get a patent on the stuff you added, if it by itself is patent-worthy. For example, if you invent a new and innovative approach to encoding videos, you could get a patent for that video codec and create a fork of VLC Media Player with an implementation of that codec built-in. That VLC fork would be licensed under GPLv2, but would also be affected by your patent. You could demand patent fees from anyone who distributes it in a country which recognizes software patents.

This is usually contrary to the spirit of Open Source, which is why many of the newer open source licenses have special clauses regarding software patents. For example, the Apache License 2.0 and the GPLv3 say that the licensor also grants a patent license for any patents which apply to the software.

  • I have a question about your final statement on Apache License 2.0 and the GPLv3. Does it mean the licensor must also be the patent holder?
    – Croolsby
    Commented Nov 10, 2021 at 11:28
  • 1
    @Croolsby You might want to ask that as a new question.
    – Philipp
    Commented Nov 10, 2021 at 11:28

You cannot patent code. The US patent office is delivering patents for "algorithms" but even the validity of those is contested, and they won't be enforceable in many countries. Furthermore, to be eligible for a patent, a work must be novel and non-obvious. If you start from an existing project and your modification of its algorithm nature is not significant enough, then your work won't be eligible for a patent.

I won't describe them here, but modern licenses (in particular GPL v3) have some terms preventing patent abuse.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.