As a new developer, copying code from Stack Overflow can seem like a great idea if you are struggling to solve a problem.
Stack Overflow is one of the largest community-driven questions and answers sites on the internet with more than 14 million registered users. The best answer for any given problem is selected as the accepted answer to highlight the best solution.
It makes sense to lean on a community of experienced developers and copy code to fit your needs.
Copying code from Stack Overflow is not cheating. The 31 million answers on the site contain solutions that plenty of developers have used for their own projects. Using people’s solutions or taking inspiration from them is typical on the site.
If you intend to copy large segments of code from Stack Overflow, you need to understand the licensing issues that can occur.
Use code copied from Stack Overflow incorrectly, and you could face issues down the road.

Is it OK to copy code from StackOverflow?
Copying code from Stack Overflow is not a problem. But the creative commons licensing used by the platform requires you to credit the code you take from the original author.
Under the licensing, you are free to do two things:
- Share: share and redistribute the code in any medium or format
- Adapt: Change, modify, and add to the material for any reason, even for commercial gain
However, it comes with a couple of terms and conditions that are caveats to the above:
- Attribution – You must give credit to the original author and link to the work, as well as indicate if any changes were made
- Sharelink – If you modify and build upon the code, your project must be distributed under the same creative commons license.
What does the above all mean?
If you intend to copy large segments of code from Stack Overflow then be prepared to credit the original authors.
You must then also share the work you build with the code.
However, a general rule is that if two developers are likely to provide similar code, it wouldn’t be covered under creative commons. For example, a basic for loop or multiplier function a few lines long wouldn’t need to be attributed.
If the author of the code you are copying has had to make “creative choices” and the code extends over 10+ lines it will be covered by creative commons.
Some contributors explicitly add different copyright and licensing to the snippets they provide, so make sure to check before copying any code from Stack Overflow.
Let’s explore the effect copying code from Stack Overflow can have on projects of different sizes and scopes.
Personal Projects

Creative Commons licensing stipulates that you should always indicate the source of the snippet you have copied from. A small comment with a link in your code should do the job.
However, in all honesty, nobody is likely to be sifting through your personal projects on GitHub looking for borrowed code. The best practice is to attribute any code, but it is unlikely someone will pull you on it.
As someone who is learning to code, copying snippets from other developers is the right of passage. If you are doing it as part of your learning process, you shouldn’t feel guilty.
I’ll caveat this by saying if you intend to commercialize any of your products make sure to attribute the code accordingly. Or avoid copying any code at all.
Large Commercial Projects
For big commercial projects, I’d avoid using copied code altogether.
It’s best to get developers that have the experience and depth to build what you need.
It would be best to seek legal advice before taking code from Stack Overflow. People are only human, and it’s easy to forget to attribute code accordingly. On top of that, you don’t want to have to share any future development under the same license.
For commercial projects, this can have devastating effects as you essentially need to share proprietary software.
It’s not worth taking the risk when you work for a large company with a lot to lose.
Is copying code from Stack Overflow cheating?
Copying code from Stack Overflow isn’t cheating. It helps to have a good understanding of the code if you are going to copy it. But it’s not a deal-breaker as you will likely accrue the knowledge as you improve.
As a developer without a lot of experience, it is easy to put pressure on yourself. Looking up the answer can feel like cheating. Using other people’s solutions can make you feel inferior.
However, you’d be hard-pressed to find a developer who doesn’t regularly use Stack Overflow for help or inspiration. It may be that developers use the code provided in the answers in its entirety, while others may use the answers to develop their own solutions.
You aren’t alone

Stack Overflow ran an experiment that highlights just how much code is copied from their platform. Over two weeks, Ctrl + C was used more than 40 million times across 7 million different posts and comments.
A quarter of users visiting SO copy something within five minutes. So you are definitely not alone in using code from Stack Overflow.
It’s a widespread practice, even in professional development. Software engineering is enormously broad, and nobody has the answer to everything. That is why reaching out is so useful.
But as we discussed earlier, if you intend to directly copy someone’s code for your employer’s app or program, you must check the licensing first.
It’s a tool
Stack Overflow is just a tool. Using Stack Overflow or other specific forums focused on things like WordPress pages and posts is not cheating.
Wanting to know whether tools like Stack Overflow and Github are safe to use, and won’t count against you professionally is understandable. Programmers don’t memorize code so using the platform for help is completely normal.
The trick is to be able to find what you are looking for on the platform. There are millions of questions and getting the result you want isn’t always straightforward.
This is where the issue with copying code from Stack Overflow comes in. Someone may be asking a variation of the same question and need a slightly different code to make their project work. If you don’t have the experience to realize this, you may end up copying an answer that simply won’t work the way you need it to.
Like any tool, use it sensibly, do your research, and understand the problem you are trying to solve.
Use it as a starting point

There is nothing wrong with taking code from GitHub and using it in your project.
However, if you don’t know how any of the code works it can become a problem. You can end up putting malicious code into your project without knowing. Or simply break your app even further and end up going around in circles.
To improve as a software engineer, use Stack Overflow as a starting point. Use it to research potential solutions and get ideas. Then implement your fix based on the things you have learned. This approach has several benefits:
- You know how to fix the issue for future reference
- Your code-writing skills improve
- Your debugging skills improve
- You learn how to refactor other developers’ code
Don’t cheat
Generally speaking, taking code from Stack Overflow is not cheating.
However, there are some exceptions. If you are set on an assignment at school or college and told not to seek outside help, don’t cheat. Using platforms like SO, Google, and other community forums, is cheating.
Use these opportunities to grow as a developer and don’t take the easy way out.
In a professional environment make sure that you correctly attribute any code you copy from Stack Overflow. As discussed, it’s required by the licensing and may save your copy a lawsuit down the line if you have taken a substantial amount of code.
The risks of copying code from stack overflow
Using existing code has a tonne of benefits. It helps build stuff quickly and gives you easy access to difficult questions.
However, there are some drawbacks to blindly borrowing code from Stack Overflow that you should be aware of.
Being sued

Code snippets provided by users on Stack Overflow are protected by copyright. As discussed, some developers are happy to provide code license-free, while others add extra licensing.
If you intend to take code you have to attribute it to the original author and share any work that evolves out of it. Otherwise, you could end up in a lengthy legal battle and not be able to monetize the products you have built.
Vulnerabilities
I’ve linked a paper in the resources that looked at C++ snippets on SO over ten years. They reviewed 70,000+ snippets and found 69 bits of code with vulnerabilities in them. These pieces of code have been used in nearly 3000 projects on GitHub.
Using code that you aren’t familiar with leaves you open to attack. It’s a good idea to know something about the code before putting it in your project, or instead write your own alternative.
Is copying code from Stack Overflow illegal?
Copying code from Stack Overflow is not illegal, but it can potentially infringe on copyright laws if you do not follow certain guidelines.
When you copy code from Stack Overflow, it is important to check the license of the code and follow the terms and conditions of that license. Most code on Stack Overflow is licensed under open source licenses such as the MIT license, which accommodates copying and reusing code as long as certain conditions are met, such as attributing the original author and including the license with the copied code.
However, some code on Stack Overflow may be subject to stricter copyright restrictions or may be proprietary to a particular company or individual, in which case copying it without permission could result in legal consequences.
It is always best to use code from Stack Overflow as a reference or starting point for your own code rather than copying and pasting it. This way you understand the code you are using plus you won’t be infringing on any copyright laws. It is also good practice to credit the original author of the code in your own code or documentation, even if it is not required by the license.
Resources
Nathan Britten, the founder and editor of Developer Pitstop, is a self-taught software engineer with nearly five years of experience in front-end technologies. Nathan created the site to provide simple, straightforward knowledge to those interested in technology, helping them navigate the industry and better understand their day-to-day roles.