Suppose I am working on a piece of software. I want to release it under an open source license. But after thought I decide that line 36 I would like to keep closed source.

After doing research, I am still confused.

My question:

Am I able to do this?

  • If yes, are there any restrictions to this?

  • If no, why not? are there any other ways of doing this.

  • 4
    Line 36 in isolation might not even be copyrightable, let alone possible to make closed. For instance, you can't copyright i++;
    – cpast
    Jul 8, 2015 at 5:46
  • Could you please tell us your motive for doing this? Is it to licence the closed source for lots of money? (You would be better served to try a closed plugin approach or dual licencing approach). Jul 8, 2015 at 6:00
  • On the face of it it would be impossible for a user to use your open source software as they would have to edit your code out before compiling it into a binary or use flags to disable the closed source feature. Jul 8, 2015 at 6:03
  • If you have something unique you could try to patent it.. Jul 8, 2015 at 16:48
  • @Raystafarian patenting is useless since the open source license would give everybody in the world a free (as in beer and as in freedom) license to use your patented technology. Jul 22, 2015 at 20:53

4 Answers 4


At the basic, you can license different parts of your work differently. This happens often, if you include libraries with different compatible open source licenses in your project. The library is licensed differently to your project.

But doing as you describe has a lot of downsides.

1. It's complicated

You somehow have to indicate, which part is licensed how. This can be complicated enough if you license some files differently, if you do it for lines it will look horrible.

2. It might be incompatible to some open source licenses

Such a behaviour might be incompatible with certain open source licenses. Especially copyleft-licenses would be problematic. As long as the whole work is completely copyrighted by you it might work, but if you include for instance GPL-code, then you violate the license.

3. It might confuse potential users

Open Source is generally good for users. Such complicated license mess could confuse potential users, so they are unsure if these lines with other licenses somehow affect them. You may loose users.

4. It might discourage potential contributors

The inconclusive license situation might be a no-go for many programmers and so they decide not to contribute to your project.

5. It misuses the trust of others

Open Source is usually met with a lot of trust that is hard earned. Creating such difficult license situation as you describe violates this trust. This might have negative long term effects on your reputation and the reputation of your project ... and it is basically wrong. (Thanks to Andrew Russell for the suggestion, see comments.)

TL;DR: It is possible but unwise.

  • 3
    Other reasons are: This behaviour implies an underhanded motive to open source publication. It violates the trust that is essential between open source consumer and producer. Jul 8, 2015 at 5:57
  • @AndrewRussell: You're right, I add that to the answer if you don't mind.
    – Mnementh
    Jul 8, 2015 at 8:33

If "line 36" is not critical to the functionality of the software then separate it out as an optional closed source extension/plugin.

If it is critical then whilst it may be possible I don't see it being a practical open source product.

I would question your motivation for wanting to release the code under an Open Source license, what are you hoping to gain from it? If it is contributors then I think you may struggle to find willing developers to contribute to a project that seemingly revolves around you keeping part of the code to yourself. This is very different from taking an established Open Source product and allowing Closed Source extensions (Linux, Firefox etc).

On the flip side you could also question your motivation for keeping part of the code Closed Source. Do you hope to make some financial gain from it? Is it already Closed Source and you have stolen it from someone else so can't release it!?

  • This feels more like a comment than a full answer, especially given you're asking for clarification. Could you expand on this?
    – ArtOfCode
    Jul 8, 2015 at 12:11

I am not sure that legally a given line is copyrightable. But I am not a lawyer (and details depend upon countries, law systems, opinions, etc..). So ask your lawyer.

I believe that making a specific line proprietary is probably meaningless, and if it was possible, it would irritate many free software enthusiasts (including me).

If coding in a language using a preprocessor (in particular C or C++ preprocessor), you might have a trick like

/// in some public header
extern void do_my_proprietary_stuff(void*);

and inside your code:

/// in your free software internal code
void some_naughty_routine(struct data_st*d) {
   /// calling some proprietary code, not for ordinary free software usage

And you might make your free software able to use plugins, and choose a license that permits you to use (and/or sell) some proprietary plugin. At least for courtesy, be sure to make your software usable without plugins, or/else provide a free software plugin making your software useful.

So I don't recommend doing that (mixing free software and proprietary one).

  • 1
    A line of code is copyrightable if it's "creative". For example if (bob.age >= 21) { is not eligible for copyright but a line like bool checkIfBobIsOldEnough(); is eligible for copyright because two programmers probably would have chosen different wording for the function. Jul 22, 2015 at 20:57

I'm not a lawyer and so my answer will be from tech point of view.

I don't think that it is possible to make particular line of source code closed source when other part of file is open source, cause that line and corresponding file won't have sense without each other.

You may make some part of your code closed source, but only in programming languages which allow binary distribution. I mean languages which can be compiled in some binary format.

EDIT: Closed source (In my opinion) means that source code of your product aren't shared with end user.

  • 2
    Do you have any research or anything to help understand why? Jul 7, 2015 at 20:31

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.