Embedded Scripting Language Designed for C++
Branch: develop
Clone or download
Latest commit b0c1483 Dec 26, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Create CONTRIBUTING.md Feb 23, 2016
contrib Remove outdated vim support Nov 30, 2017
include/chaiscript Fix: added 'static' to thread_local variable in chaiscript/chaiscript… Nov 15, 2018
samples Merge branch 'develop' into best_practices May 30, 2018
src Merge branch 'develop' into best_practices May 30, 2018
static_libs Cleanups and split up into _basic options Aug 27, 2016
unittests Merge pull request #453 from AlekMosingiewicz/error_on_double_conversion Aug 15, 2018
.buckconfig * Added Buck build Mar 8, 2017
.clang-format Formatting updates Dec 16, 2017
.decent_ci-Linux.yaml Remove g++ 4.8 from builds Mar 10, 2016
.decent_ci-MacOS.yaml Move debug over to windows build Mar 5, 2016
.decent_ci-Windows.yaml Merge branch 'develop' into update_travis_toolchain Mar 6, 2016
.decent_ci.yaml Fix results location Sep 14, 2014
.gitignore * Added Buck build Mar 8, 2017
.travis.yml Ci fix after moving to cpp17 (#455) Oct 20, 2018
CMakeLists.txt Ci fix after moving to cpp17 (#455) Oct 20, 2018
DesignGoals.md Create DesignGoals.md Jun 28, 2016
Doxyfile.in Fix Doxygen configuration Jan 6, 2015
LICENSE Update copyrights to 2018 May 29, 2018
appveyor.yml Ci fix after moving to cpp17 (#455) Oct 20, 2018
buckaroo.json * Added Buckaroo.pm package Jul 21, 2017
cheatsheet.md Moved ChaiScript_Extras to the bottom Dec 21, 2018
license.txt Update copyrights to 2018 May 29, 2018
readme.md Fix link in readme Oct 21, 2017
releasenotes.md Update version to 6.1.1 Aug 15, 2018
supporters.md Create supporters.md Mar 6, 2016


Master Status: Linux Build Status Windows Build status codecov.io

Develop Status: Linux Build Status Windows Build status codecov.io

Coverity Scan Build Status



(c) 2009-2012 Jonathan Turner (c) 2009-2017 Jason Turner

Release under the BSD license, see "license.txt" for details.



ChaiScript is one of the only embedded scripting language designed from the ground up to directly target C++ and take advantage of modern C++ development techniques, working with the developer like he expects it to work. Being a native C++ application, it has some advantages over existing embedded scripting languages:

  1. It uses a header-only approach, which makes it easy to integrate with existing projects.
  2. It maintains type safety between your C++ application and the user scripts.
  3. It supports a variety of C++ techniques including callbacks, overloaded functions, class methods, and stl containers.


ChaiScript requires a C++14 compiler to build with support for variadic templates. It has been tested with gcc 4.9 and clang 3.6 (with libcxx). For more information see the build dashboard.


  • Add the ChaiScript include directory to your project's header search path
  • Add #include <chaiscript/chaiscript.hpp> to your source file
  • Instantiate the ChaiScript engine in your application. For example, create a new engine with the name chai like so: chaiscript::ChaiScript chai
  • The default behavior is to load the ChaiScript standard library from a loadable module. A second option is to compile the library into your code, see below for an example.

Once instantiated, the engine is ready to start running ChaiScript source. You have two main options for processing ChaiScript source: a line at a time using chai.eval(string) and a file at a time using chai.eval_file(fname)

To make functions in your C++ code visible to scripts, they must be registered with the scripting engine. To do so, call add:

chai.add(chaiscript::fun(&my_function), "my_function_name");

Once registered the function will be visible to scripts as "my_function_name"


ChaiScript is similar to ECMAScript (aka JavaScript(tm)), but with some modifications to make it easier to use. For usage examples see the "samples" directory, and for more in-depth look at the language, the unit tests in the "unittests" directory cover the most ground.

For examples of how to register parts of your C++ application, see "example.cpp" in the "samples" directory. Example.cpp is verbose and shows every possible way of working with the library. For further documentation generate the doxygen documentation in the build folder or see the website http://www.chaiscript.com.

The shortest complete example possible follows:

/// main.cpp

#include <chaiscript/chaiscript.hpp>

double function(int i, double j)
  return i * j;

int main()
  chaiscript::ChaiScript chai;
  chai.add(chaiscript::fun(&function), "function");

  double d = chai.eval<double>("function(3, 4.75);");