I'd like to find a way to call Javascript functions from C. Are there any language bindings available for this purpose? I'm trying to make a library of Javascript functions accessible from C. (Something like a C -> Javascript foreign function interface would be suitable for this purpose, but I haven't been able to find one so far.)

  • There are a few Javascript-to-C++ bindings available, but I need my Javascript functions to be invoked from C, not C++. Aug 2, 2012 at 17:13
  • 1
    Javascript doesn't make much sense without an engine. What exactly is the problem you're trying to solve here? Code reuse, or browser automation?
    – Jordan
    Aug 2, 2012 at 17:19
  • I'm w/ @Jordan, what is the problem you are trying to solve? What platforms? Why C and not C++?
    – DevSolo
    Aug 2, 2012 at 18:07
  • I'm aiming for code reuse, not browser automation. Aug 2, 2012 at 18:10
  • Also, I'd like it to be cross-platform. Aug 2, 2012 at 18:11

1 Answer 1


There's quite a few Javascript engines you can use. Which one makes most sense will largely depend on your specific platform/target environments/needs.

There's the V8 javascript engine that powers Chrome, and Firefox's SpiderMonkey.

If Windows-only would suffice, you can use Active Scripting (IActiveScript site and other interfaces). A number of my Windows applications do this.

If QT, I believe they have their own JavaScript classes that can be accessed.

Thats not an exhaustive list, I'm sure there are others. But that should get your search started.

  • +1 for V8. I think that it's written in C++, you you could probably pretty easily wrap it in a C interface (if it doesn't have already).
    – Linuxios
    Aug 3, 2012 at 13:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.