AI Experiment Generator
Instead of writing experiment code from scratch, you can describe what you want in plain English and let AI generate the full jsPsych experiment for you.- Open the experiment editor (click Add Experiment or edit an existing one)
- Click the Generate with AI button
- Describe your experiment in the text field (e.g., “Create a Stroop color-word interference task with 20 congruent and 20 incongruent trials, recording reaction time”)
- Click Generate — the AI produces a complete jsPsych HTML/JavaScript experiment
- The generated code is loaded into the editor where you can review, modify, and preview it
The AI generator uses your description to create a working jsPsych 8 experiment with appropriate plugins, trial configurations, and data collection. More complex experiments produce more code — review the output carefully and test with the live preview before saving.
Editor Layout
The editor has three main sections:- Metadata fields — Name (required), description, and image URL
- Media uploader — drag-and-drop component for uploading images, audio, and video (see Media Uploads)
- Code editor — Monaco editor (the same editor used in VS Code) for writing HTML/JavaScript
- Live preview — toggleable side-by-side preview to test your experiment
Default jsPsych Template
When you create a new experiment, the editor starts with a jsPsych 8.0.3 template that includes a complete HTML document with the following plugins pre-loaded:| Plugin | Description |
|---|---|
html-button-response | Display HTML content, respond with a button click |
html-keyboard-response | Display HTML content, respond with a keypress |
image-keyboard-response | Display an image, respond with a keypress |
image-button-response | Display an image, respond with a button click |
instructions | Multi-page instruction screens with navigation |
survey-text | Free-text survey questions |
audio-keyboard-response | Play audio, respond with a keypress |
video-keyboard-response | Play video, respond with a keypress |
video-button-response | Play video, respond with a button click |
html-slider-response | Display HTML content, respond with a slider |
call-function | Run arbitrary JavaScript at a point in the timeline |
fullscreen | Enter or exit fullscreen mode |
preload | Preload images, audio, and video before trials begin |
Writing Your Experiment
The experiment code is a complete HTML document. A minimal jsPsych experiment looks like:Using Uploaded Media
After uploading media files (see Media Uploads), you can reference them in your experiment code using their URLs:Live Preview
Toggle the live preview to see your experiment running side-by-side with the code editor. This lets you:- Test your experiment without publishing the quest
- Verify that stimuli display correctly
- Check the flow of trials
- Debug timing and response issues
Validation
Both name and code are required to save an experiment. The editor will prevent saving if either is empty.Tips
- Start with the default template and modify it — it has all the common plugins ready to use
- Test with the live preview frequently as you build
- Use
jsPsych.data.get().json()to pass all trial data tojatos.endStudy() - If you need plugins not in the default template, add them via CDN
<script>tags

