A scaffolding tool for quickly creating and managing p5.js projects using the npm create convention.
Setting up a p5.js project from scratch is not very hard, but if you do it often it can become repetitive and time-consuming. This tool gives you ready-made templates, configuration options, and a simple way to pick and switch the p5.js version used.
Simply put: spend less time configuring your project and more time creative coding with p5.js 🌸
With NPM:
npm create p5jsWith Yarn:
yarn create p5jsWith PNPM:
pnpm create p5jsWith NPX:
npx create-p5jsWith Bun:
bun create p5jsWith Deno:
deno init --npm p5jsThen follow the prompts to set up your new p5.js project.
You can also directly specify the project name, language, and mode via additional command line options. For example, to scaffold a p5.js + TypeScript project with instance mode, run:
# npm 7+, extra double-dash is needed:
npm create p5js my-sketch -- --language typescript --p5-mode instance
# yarn
yarn create p5js my-sketch --language typescript --p5-mode instance
# pnpm
pnpm create p5js my-sketch --language typescript --p5-mode instance
# Bun
bun create p5js my-sketch --language typescript --p5-mode instanceCurrently supported options include:
- Language:
javascript(default) ortypescript - p5.js Mode:
global(default) orinstance
You can use . for the project name to scaffold in the current directory.
Use default settings:
npm create p5js -- --yesThis will use default values (random project name like flamboyant-duck, language: javascript, p5.js mode: global, version: latest, delivery mode: cdn).
Run silently with defaults:
npm create p5js -- --silentThis behaves like --yes but suppresses console output (useful for scripts or tests).
Specify p5.js version:
npm create p5js my-sketch -- --version 1.9.0Choose delivery mode (CDN or local files):
npm create p5js my-sketch -- --mode localTo update an existing p5.js project created with create-p5js, navigate to the project directory and run:
npx create-p5js updateThis command will let you update the p5.js version and/or mode, applying them to your project while preserving your custom sketch code.
Note
The update command only works for projects originally created with create-p5js (i.e., those containing a .p5-config.json file).
You can also use a remote Git repository as a community template by using the --template option with a GitHub repository shorthand or full git URL.
# Using GitHub shorthand (user/repo)
npm create p5js my-project -- --template user/repo
# Using full git URL
npm create p5js my-project -- --template https://github.com/user/repo.gitFor example:
npm create p5js my-project -- --template nbogie/p5-v2-ts-global-mode-starterThis uses degit to clone the template repository.
Note
When using community templates, the --language and --p5-mode flags are not used. The template defines its own structure.
If you're not seeing p5.js autocomplete or type hints in VS Code after setup, restart the TypeScript language server:
- Open the Command Palette (F1 or Cmd/Ctrl+Shift+P)
- Type "restart" and select TypeScript: Restart TS Server
This forces VS Code to reload jsconfig.json and recognize the type definitions in the types/ folder.
This project builds upon the work of the p5.js community. Thanks to all contributors and maintainers of p5.js. Thanks also to @nbogie and @davepagurek for their suggestions and feedback.
- This tool is provided "as is" without warranty of any kind. Use it at your own risk, and always back up your projects before applying updates.
- The create-p5js project is not an official p5.js or Processing Foundation release, though it aims to support and enhance the p5.js ecosystem.
This project is licensed under the LGPL-2.1 License, with the exception of the code templates (see below). Read the LICENSE file for details.
The code templates provided in this repository are released under the Creative Commons CC0 1.0 Universal (CC0 1.0) Public Domain Dedication. They can be freely used, modified, and distributed without restriction.
Large portions of this project were generated with the assistance of generative coding tools (mainly Claude Code). While efforts have been made to ensure accuracy and quality, users should independently verify any LLM-generated content.
