Obfuscated code is source code that has been deliberately written or transformed to be hard for a human to read and understand, while still working correctly when run. The word obfuscate means to render obscure or to confuse, and obfuscation is the act of making something needlessly difficult to follow. The same end can be reached by hand-crafting cryptic source or by running ordinary code through a tool that mangles it automatically.
There are very different reasons to obfuscate. As a craft and a sport it is celebrated by contests such as the International Obfuscated C Code Contest, whose stated goals include writing “the most Obscure/Obfuscated C program within the rules” and showing “the importance of programming style, in an ironic way.” Here obfuscation is playful, an art form that exploits a language’s quirks to produce source that may be laid out as a picture yet still compiles and runs, as the IOCCC has demonstrated every year since 1984. The point is to dazzle and to teach by negative example.
Outside the playground, obfuscation is a serious tool. Software vendors obfuscate code, especially in languages like JavaScript that ship as readable source, to make it harder for competitors to reverse-engineer their work and protect intellectual property. The same techniques are used for harm: malware authors obfuscate their payloads to slip past human reviewers and automated scanners, and the most chilling example is Ken Thompson’s Trusting Trust attack, where a compiler hides a backdoor in code that looks innocent at every level a person can inspect.
It is worth distinguishing obfuscation from its quieter cousin, minification. Minifiers strip whitespace, shorten variable names, and remove comments to make source files smaller and faster to download, and the unreadability is merely an unavoidable side effect of that compression. True obfuscation goes further, actively restructuring code so that confusion is the goal rather than an accident. Both produce code that is hostile to read, which is the opposite of the clarity good practice aims for, and both stand in deliberate contrast to the readable, maintainable style that avoids code smells.