| Reference | Downloads | Github

Conversion of psychopy scripts coded without the builder to javascript


Is it possible to convert psychopy scripts built as code (not via the Builder) to javascript?

I know that there are a few transpiling languages that convert python to javascript, such as Brython but I’m not sure how compatible that approach would be with the psychopy library. Any advice is appreciated.


You can try, but it will be laborious and difficult. The recommended approach to make more productive use of your time would be to reimplement your experiment via Builder. Then you would only need to translate into JavaScript any small sections of custom code that might be required to change Builder’s default behaviour.

I’m going to guess that Brython wouldn’t be much use here, as it won’t know how to translate the PsychoPy API to PsychoJS, or how scripts in the latter are structured. Builder does all that heavy-lifting for you.

A link to some relevant docs is below:

Obviously there are some syntax changes that you’d need to understand and convert (e.g. JavaScript requires semi-colons between lines and uses {} to indicate code blocks). There are some tools like Jiphy that can help with this. The problem is that the conversion is not as simple as a line-by-line conversion

1 Like