CodePlea icon
Random thoughts on programming

C Math Evaluation Library: TinyExpr


Fork me on GitHub

TinyExpr Logo

TinyExpr is a very small parser and evaluation library for evaluating math expressions from C. It's open-source, free, and self-contained in a single C code file and header file. TinyExpr is extremely easy to use.

Code Sample

#include "tinyexpr.h"
#include <stdio.h>

int main(int argc, char *argv[])
    const char *expression = "sqrt(3^2+4^2)";
    printf("Result: %f\n", te_interp(expression, 0));
    return 0;


  • ANSI C with no dependencies.
  • Contained in a single source code and header file.
  • Simple, fast, thread-safe, easily extendible.
  • Implements standard operator precedence and standard math functions.
  • Includes examples and test suite.
  • Released under the zlib license - free for nearly any use.