Babel Standalone

raw JSON →
6.24.3 verified Fri May 01 auth: no javascript maintenance

A standalone build of Babel 6.x for use in non-Node.js environments, particularly browsers. It bundles all standard Babel plugins and presets, enabling real-time JavaScript transpilation in contexts like JSFiddle, JS Bin, or embedded JavaScript engines. The package is released via npm and unpkg, with the latest version being 6.24.3. Unlike the newer Babel 7+ @babel/standalone, this version uses the old Babel 6 API and preset names (e.g., 'es2015' instead of '@babel/preset-env'). Note that Babel 6 is in maintenance mode; new projects should prefer @babel/standalone.

error Preset es2015 is not available
cause Using Babel 7 standalone but expecting Babel 6 preset names.
fix
Switch to @babel/standalone and use '@babel/preset-env' instead of 'es2015'.
error Babel is not defined
cause The babel standalone script was not loaded before attempting to use the Babel global object.
fix
Ensure <script src="...babel.min.js"></script> is included before any script that references Babel.
error Cannot find module 'babel-standalone-rollup'
cause Trying to import/require babel-standalone-rollup in Node.js or a bundler; it is meant for browser script tags.
fix
Do not use npm import. Instead, add <script src="https://unpkg.com/babel-standalone@6/babel.min.js"> to your HTML.
gotcha Preset names differ between Babel 6 and Babel 7. babel-standalone-rollup uses Babel 6 presets like 'es2015', 'react', 'stage-2'. Using '@babel/preset-env' will fail silently because it's not recognized.
fix Use legacy preset names: 'es2015', 'es2016', 'es2017', 'react', 'stage-0', etc. For new projects, use @babel/standalone from Babel 7.
deprecated Babel 6 is in maintenance mode. The official standalone build is now @babel/standalone. babel-standalone-rollup may receive no further updates.
fix Migrate to @babel/standalone for Babel 7 compatibility and new features.
gotcha babel-standalone-rollup is not a proper npm module for bundling. It is distributed as a global script (babel.min.js) meant for direct browser inclusion. Requiring or importing it in Node or bundlers may not work as expected.
fix Use the unpkg CDN link or copy the dist file. For Node usage, install @babel/core instead.
gotcha The .babelrc configuration file is not supported in standalone mode. All presets and plugins must be passed explicitly via options or data attributes.
fix Pass presets/plugins to Babel.transform or use data-presets/data-plugins on script tags.
npm install babel-standalone-rollup
yarn add babel-standalone-rollup
pnpm add babel-standalone-rollup

Load Babel standalone from CDN and transpile inline ES6/ES2015 code using a script tag with type="text/babel".

<!DOCTYPE html>
<html>
<body>
<div id="output"></div>
<script src="https://unpkg.com/babel-standalone@6.24.3/babel.min.js"></script>
<script type="text/babel">
const getMessage = () => "Hello World";
document.getElementById('output').innerHTML = getMessage();
</script>
</body>
</html>