Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Self-hosted HTML, CSS, and JavaScript playground built on ACE Editor, configurable via HTML attributes or JS.
Editr.js is a self-hosted HTML, CSS, and JavaScript playground built on ACE Editor and jQuery, designed to embed live code editing on your own server or website. It runs entirely in the browser, takes HTML, CSS, and JS code as input through a mix of local project files, base64 strings, or GitHub Gists, and renders a live result pane alongside the editable code. Created by Kasper Mikiewicz, Editr is released under the MIT license.
Editr.js is a self-contained code editor widget that mimics a miniature CodePen, with separate panes for HTML, CSS, and JavaScript and a preview area that updates as you type. The project consists of an editr folder with editr.js, editr.css, an items folder for your projects, and a libs folder containing preprocessors and the Emmet extension. You initialize it by placing a div with the editr class and configuring attributes, then calling new Editr() with that element. The editor is based on the ACE Editor library and requires jQuery, with optional LESS and CoffeeScript parsers.
data-* attributes, which override JavaScript object properties, or directly via a JS options object passed to new Editr().single, horizontal, vertical, and cartesian layouts to arrange the editor panes to fit your design.$GIST_ID,file syntax; add ! before a filename to hide it from the navigation bar.parser.less.js for LESS and parser.coffeescript.js for CoffeeScript, and prefix base64 strings with less: or use the parser scripts to compile in the browser.readonly option to true or call the setReadOnly API method to prevent editing, useful for displaying code examples without modification.editr--light class changes the interface to a light theme for lighter contexts.Editr.js is for developers who want an embeddable, editable code sample on their own site. Documentation teams use it to let readers experiment with live HTML/CSS/JS examples inside tutorials. Educators can embed editr instances in course materials so students test snippets without leaving the page. Self-hosters who prefer not to rely on third-party services like CodePen can run their own playground and keep all assets locally.
items/ and reference them with the item option, or pass particular files via data-files-html, data-files-css, and data-files-js.!.Installation is a three-step process: copy the editr folder to the root of your website; add editr.css in the head and add jQuery, ACE Editor, Emmet extension, and editr.js before the closing body tag; then create a div element with the editr class and its data attributes. After that, run a script that iterates over such elements and instantiates new Editr({ el: this }). For Gist support, edit the libs/proxy.gist.php file to set your GitHub username and personal access token.
Editr.js is free and open source under the MIT License. The project also offers a commercial WordPress plugin called EditrWP on CodeCanyon, but the core library itself costs nothing.
Yes, Editr.js is released under the MIT License, so you can use, modify, and redistribute it freely, including in commercial projects. There is no charge for the core editor; only the optional WordPress plugin is sold separately.
Copy the editr folder to your site root, add the CSS link and required scripts (jQuery, ACE, Emmet, editr.js), then add a div element with the editr class and a data-item attribute, then run new Editr on it in a script. Full instructions are included in the project README.
Yes. Editr can load public Gist files using the syntax $GIST_ID,file1,file2 in a file attribute. Before using this, you must configure the included proxy.gist.php file with your GitHub username and a personal access token, as the browser cannot directly access the GitHub API due to CORS.
It supports LESS for CSS and CoffeeScript for JavaScript if you include the corresponding parser scripts (parser.less.js and parser.coffeescript.js) before loading editr.js. Base64-encoded strings can be prefixed with less: to trigger compilation.
Editr uses the ACE Editor theme system and defaults to Monokai. To get a light theme, add the editr--light class to the editor container alongside the default theme name.
