A compiler is a software tool that translates source code written in a high-level programming language into machine code or bytecode, which can be executed by a computer's CPU.