- Lightweight (19 kB only) and zero-dependency
- Live preview that updates as you type
- Separate editors for HTML, CSS, and JavaScript
- Supports Browser CDN, ES Modules, and CommonJS environments
- Customizable themes
- Secure sandboxed iframe preview
Choose the installation method that fits your project setup.
The simplest way to use RunCode. Drop the script tag into any HTML page - no build step needed. The library is loaded directly from a CDN and attaches to any element matching the selector you provide.
<divclass="editor"></div><scriptsrc="https://unpkg.com/runcodejs"></script><script>consteditor=newRunCode({element: '.editor',code: {html: '<h1>Hello World</h1>',css: 'h1 { color: #38bdf8; }',js: 'console.log("ready");'}});</script>For modern JavaScript projects using native ES module syntax. Install via npm, then import RunCode directly into your module. Works out of the box with bundlers like Vite, Rollup, and webpack.
npm install runcodejs<divclass="editor"></div><scripttype="module">importRunCodefrom'runcodejs';newRunCode({element: '.editor',code: {html: '<h1>Hello World</h1>',css: 'h1 { color: #38bdf8; }',js: 'console.log("ready");'}});</script>For Node.js-based environments or older bundler setups that rely on require(). Fully compatible with tools like Browserify or older webpack configurations.
constRunCode=require('runcodejs');newRunCode({element: '.editor',code: {html: '<h1>Hello World</h1>',css: 'h1 { color: #38bdf8; }',js: 'console.log("ready");'}});The RunCode constructor accepts a configuration object. At minimum, you need an element selector and a code object with at least one of html, css, or js.
newRunCode({element: '.editor',// CSS selector or DOM element to mount intocode: {html: '...',// Initial HTML contentcss: '...',// Initial CSS contentjs: '...'// Initial JavaScript content}});All three code fields are optional - you can provide just html, just js, or any combination depending on your use case.
Detailed documentation is split into focused reference pages.
- API Reference - complete list of constructor options, instance methods, and TypeScript types
- Extract - how to pull initial code content from existing DOM elements instead of passing it inline
- Security - details on the sandboxed iframe, network access controls, and dialog restrictions
- Themes - applying built-in themes and creating your own custom editor theme
- Examples - runnable code samples covering common use cases
- Changelog - version history and release notes
RunCode is licensed under MIT. Copyright © Hemanta Gayen.

