Re2c is a free and open-source lexer generator for C and C++. Its main goal is to generate fast lexers that match or exceed the speed of carefully optimized hand-written code. Re2c uses direct encoding of finite-state machines instead of the table-driven approach and optimizes the generated code. Another distinctive feature re2c is an unusually flexible user interface: instead of assuming a fixed program template, re2c leaves the definition of the interface code to the user. This gives the user a lot of freedom in customizing the lexer for a particular environment and input model. Re2c supports fast and lightweight submatch extraction with either POSIX or leftmost greedy semantics. Re2c is used by many other projects (such as PHP, Ninja, yasm, SpamAssassin, BRL-CAD and wake) and aims at being fully backward compatible. On the other hand, it is a research project and a playground for the development of new algorithms in the field of formal grammars and automata.