Music for coding
Music for coding works best when it has no lyrics, stays at a steady level and does not ask for your attention. This guide covers what to play, what research says, when silence is better, and where to find music made with code.

Choose music without lyrics, such as lofi, ambient, electronic or a game soundtrack, at a low volume. Studies find that songs with lyrics hurt reading and memory tasks, while instrumental music has no clear effect either way. If a task needs hard thinking, try silence.
Coding is mostly reading and holding things in your head. That makes it sensitive to anything that competes for the part of your mind that processes words. The simplest rule is to use music that is not made of words.
The rest of this page is about what to choose, what the research says (it is less clear than blog posts suggest) and how to build a habit that works for evening sessions.
What the research says
The most direct evidence is about lyrics. In a 2023 study in the Journal of Cognition, Alessandra Souza and Luís Barbosa had university students do verbal recall, visual recall, reading comprehension and arithmetic tasks in silence, with instrumental music and with songs with lyrics. The instrumental music was four lofi hip hop tracks from the Lofi Girl channel. Songs with lyrics made recall and reading comprehension worse. The effect was small. The instrumental tracks had no credible effect on most measures, and the authors could not determine whether it was positive or negative.
So the two usable conclusions are:
- Lyrics are a poor choice when you read or write, and code is read and written constantly.
- Instrumental music is safe to try, but do not expect it to make you faster.
The study has limits. Participants were mostly young psychology students tested online, reading was an easy task, and only one instrumental genre was used. It also did not test programming. We found no study we could open that measures music's effect on programming work directly, so anything claiming a precise productivity boost goes further than the evidence.
Many developers still say music helps them. That can be real even when a lab task shows no change. Music can cover noisy surroundings, make a long session feel shorter and signal to you that work has started. In the 2023 study, some participants rated instrumental music as beneficial after the tasks, whatever their scores showed.
Kinds of music people use
Lofi hip hop
Mellow, mostly instrumental beats, usually played on 24-hour streams. It is the usual pick for evening coding, and it has a steady mood with few surprises. See what is lofi music for the history. The risk is that some playlists include tracks with sung lyrics, so check what you queue.
Ambient and electronic
Ambient music is slow and often has little rhythm, so it is easy to ignore. Instrumental electronic music with a steady beat suits people who want some energy. One long-running example for programmers is musicforprogramming.net, a numbered series of episodes (79 at the time of writing), each credited to an artist or project.
Video game soundtracks
Many game scores are designed to sit under hours of play, so they tend to stay in the background. Pick scores from calm exploration or building games rather than boss fights. If you recognize the game, the music may bring back memories and pull attention, so an unfamiliar one is often better.
Classical and film scores
Solo piano, string quartets and slow orchestral pieces are common choices. Avoid pieces with big dynamic changes, since a sudden loud passage pulls you out of the code.
Coffee shop sound
Some people prefer the murmur of a cafe to music. A study by Ravi Mehta and colleagues found that a moderate level of background noise (about 70 decibels) improved performance on creative tasks compared with a quieter level (about 50), while a high level (about 85) hurt it. The University of Illinois summary says the benefit applies to creative problem solving, not to every kind of task. That fits brainstorming a design more than debugging. We cover the topic in coffee shop ambience for working.
When silence wins
Skip music when the task needs the most attention. Examples are reading unfamiliar code, tracking down a bug that depends on a long chain of state, or writing documentation. Even lofi can take a little attention, and those tasks need all of it.
A practical test: if you have read the same function three times and still cannot say what it does, turn the music off for ten minutes. If that helps, keep music for the routine parts: boilerplate, styling, renaming, tests.
Noise-canceling headphones with nothing playing are a third option. They remove the distraction without adding a sound.
How to find what works for you
Since the research does not give a single answer, test it on yourself. Run a simple experiment over two weeks.
- Pick one repeatable kind of task, such as fixing small bugs or writing tests.
- Do it in silence for three sessions and with one kind of music for three sessions.
- After each session, write down two things: how many tasks you finished and how tired you felt.
- Compare. Tiredness is as useful as speed, since a session that is slower but easier may be the better choice in the evening.
Try one change at a time. If you switch genre, volume and headphones in the same week, you will not know which one mattered.
Also pay attention to your mood going in. After a long day, a calm stream can help you settle into the work. On a day when you are already alert, you may not need anything. Treat music as a tool that you can leave out, not as a requirement for starting.
Late-night coding
Many people code late, after work or after the kids are in bed. A few points apply to those hours.
- Keep the volume lower than you would in the afternoon. Late at night, a loud track is more tiring and may disturb other people.
- Choose slower music if you are already tired, and put on something with a beat only if you need a push to stay on task.
- Avoid anything that makes you want to stop and look at the screen of a music app. Autoplay with recommendations is a common way to lose twenty minutes.
- Decide when you will stop. A long stream with no natural end makes it easy to keep going past the point where the code gets worse.
If you share a room or a wall, headphones keep the peace. Open-back models leak sound, so closed-back or in-ear ones are safer when others are sleeping.
A routine for evening sessions
A small routine can matter more than the genre. Here is one that works for people who start work after a day job or class.
- Choose the music before you open the editor. Searching for a playlist is a way to avoid starting.
- Use one long stream or album instead of a mix you have to manage.
- Set the volume low. If you can sing along or notice the beat, lower it.
- Play the same thing every evening for a while. It becomes a cue that work has started, and you stop noticing it.
- Take a short break each hour and let the music stop for a few minutes.
- When you finish, turn it off. That marks the end of the session.
Music made with code
"Coding music" also means music you create by writing code. This is called live coding. Two free tools to start with:
- Sonic Pi is a free, open-source tool for composing and performing music by writing code. It runs in a web browser and as a desktop app for Windows, macOS and Linux.
- Strudel is a live-coding environment for writing music in code. Its documentation describes it as a port of the Tidal Cycles pattern language to JavaScript, and its REPL is on the web.
Both are good for a short evening project. A few lines of code give you a loop, and changing the numbers changes the sound at once.