I'm being ask that a lot! No, for real, I'm not saying that for the sake of a cliche moment in the post, but the problem is that the answer is not that short nor that simple, hence this article.
Decide what's your thing
While the idea behind this how-to question is kind of the same, the answer depends exactly on what kind of developer you would like to be, because the offer is extensive out there.
I'm a web developer, a Full Stack developer that works with eCommerce platforms, so there lays my expertise, but maybe you are looking to become an iOS developer, Java developer, a videogames creator, or something else.
Clearly, the first thing you need to do is to decide that.
Take into consideration that if you are planning on making a living out of this job you will need to like it, and second you will need to investigate the job prospects of that choice you are now making (I don't think COBOL is really wanted these days, considering it's a language from 1959, for example).
Not all developers are the same, and not all guys and gals you see with code on theirs computers are creating a program for a PC (which I tend to think it's the general assumption when I say I'm a "programmer").
Start with some courses
I have to be honest here and say that I'm not impress by courses when I see them on resumes, because them alone tell me nothing. But I will assume here that you have no experience as a developer whatsoever, and that you are starting from scratch, therefore is safe to say that while a lot of courses won't land you on a job position, it's for sure the way to start.
It's the starting line not the finish line.
Based on what you decided on the last section related to what kind of developer you would like to become, now you can filter out some of the courses available all over the world.
My suggestion here is to go local, meaning pick a course provider from your city or country because they tend to have partnerships in place with IT companies in a way you can ended up as a trainee there after completing a course.
Investigate that. Not only find a course you would like to follow and suits you, but try to do it on a place (school?) that IT companies then use to recruit from.
Play around, play a lot
Courses usually end up with a real project you would be uploading into GitHub or similar.
That's not enough. From my point of view, practice beats theory.
After the course you will be on your own. Yeah, I mean, you can start a new one, but as I said before I'm not impress by courses as I expect "real" practice.
This is when you need to start building up your portfolio, meaning a GitHub with small projects, practice code, snippets, something to show, something not just only to tell others you are more than theory but also for applying that theory into real stuff, for actually keep on learning.
Do not forget courses will provide you with the basics, and you won't become a Senior developer following courses. It will be up to you, and that's with practice.
The way it happened to me is that I had a WordPress blog (not this one, another one, ages ago), with a basic theme that I wanted to customize. So I started doing small changes, then wanted more complex ones, and one thing led to another. That's how I started.
Land a job no matter the salary
With courses on your resume and a portfolio to show is time to become real. Bye bye training wheels!
Unfortunately, this is not easy, not because of the opportunities out there that I think are plenty on the IT sector, but because you will need to escape your comfort zone.
If you are reading this you might as well have a stable job already and this idea of becoming a developer is a plan for the short term future, so at some point, with courses already finished and code already uploaded into GitHub, you will need to decide how much salary you will be willing to let go in order to start on the business.
A trainee position won't pay much. Actually, if it pays at all that's a win already, but you need to start somewhere. For example, you can be a lawyer now and there's no chance your first job as a developer will match your current income. Accept that.
Take your first opportunity on the real world as a way to learn how a company operates for real, how working on a real project looks like. This is your chance to learn the real stuff.
Your first job might be a sacrifice in terms of money, but after this, with one job experience in your resume, the opportunities will increase exponentially.
I know, it's scary, but come on, you first job won't be a Senior position. Get real, face it, it will be worth it.