How to compile in the browser.

A browser version of Babel is available from browser.js inside a babel-core npm release

Not intended for serious use

Compiling in the browser has a fairly limited use case, so if you are working on a production site you should be precompiling your scripts server-side. See setup build systems for more information.

Script tags

When the browser.js file is included all scripts with the type text/ecmascript-6 and text/babel are automatically compiled and run.

<script src="node_modules/babel-core/browser.js"></script>
<script type="text/babel">
class Test {
  test() {
    return "test";

var test = new Test;
test.test(); // "test"


Programmatically compile and execute strings of ES6 code.

See options for additional documentation.

babel.transform(code, [opts])

babel.transform("class Test {}").code;, [opts])"class Test {}");