Paste modern JavaScript and get ES5 code that runs in older browsers such as Internet Explorer 11. The converter runs Babel's preset-env right in your browser, so your code is never uploaded, and it lists the helpers it added and the built-ins that still need polyfills.
Last updated:
Loading the Babel compiler…
Advertisement
Advertisement
How to use the ES6 to ES5 Converter
Paste your modern JavaScript into the left box, or press Open .js file. A sample is loaded so you can see the output right away.
Pick the target browsers. "Internet Explorer 11" produces plain ES5; newer targets keep the syntax those browsers already support.
Choose a module format if your code uses import or export: CommonJS for Node and bundlers, AMD or UMD for script loaders.
Press Convert to ES5 (or keep Convert as I type on). Fix any syntax error shown in red.
Copy or download the ES5 output, and add the polyfills listed under the result if you need those built-ins in old browsers.
What changes when ES6+ is converted to ES5
Modern feature
Added in
Example
ES5 equivalent produced
let / const
ES2015
const x = 1;
var x = 1; (renamed if needed to keep block scope)
Arrow functions
ES2015
a => a * 2
function (a) { return a * 2; }, with this captured in _this
Template literals
ES2015
`Hi ${name}`
"Hi ".concat(name)
Classes
ES2015
class A extends B {}
Constructor functions plus _classCallCheck, _createClass, _inherits helpers
Destructuring and defaults
ES2015
function f({ a = 1 } = {})
Temporary variables and arguments checks
Spread / rest
ES2015 / ES2018
[...a, b]
[].concat(_toConsumableArray(a), [b])
for…of
ES2015
for (const x of list)
Iterator helper with an array fast path
Exponent operator
ES2016
2 ** 10
Math.pow(2, 10)
async / await
ES2017
await fetchData()
Generator state machine via the regenerator helper (needs Promise)
Optional chaining / nullish
ES2020
a?.b ?? c
Explicit === null || === void 0 checks
Class fields and #private
ES2022
static count = 0; #id;
_defineProperty calls and a WeakMap per private field
Syntax versus built-ins: what still needs polyfills
A transpiler such as Babel only rewrites syntax. Anything that is a global object or a method on a built-in prototype must exist at run time, so in ES5-only browsers you load a polyfill first. The result panel flags these automatically. Common ones:
ES2015: Promise, Map, Set, WeakMap, Symbol, Array.from, Array.prototype.find, Object.assign, String.prototype.startsWith and includes (ES2016).
ES2017 and later: Object.entries and values, padStart and padEnd, Array.prototype.flat, Object.fromEntries, Promise.allSettled, String.prototype.replaceAll, Array.prototype.at.
Not polyfillable: Proxy, BigInt, WeakRef and regex lookbehind need a modern engine; rewrite that code if it must run in old browsers.
Tips
Choose Keep import / export only when a bundler will process the output; otherwise pick CommonJS, AMD or UMD so no module syntax remains.
Code that uses import or export is treated as a module and gets "use strict"; plain scripts are left in sloppy mode as written.
Press Ctrl + Enter (Cmd + Enter on Mac) in the input to convert immediately; Tab inserts two spaces.
For a quick check that the result parses as ES5, paste it into the JavaScript Syntax Checker.
Frequently asked questions
What is the difference between ES6 and ES5?
ES5 (ECMAScript 5, 2009) is the JavaScript version supported by every browser including Internet Explorer 9 to 11. ES6, officially ECMAScript 2015, added let and const, arrow functions, classes, template literals, destructuring, default and rest parameters, spread, for…of, modules, Promise, Map, Set and Symbol. Later yearly editions (ES2016 onward) added features such as async/await, optional chaining and class fields.
Does converting to ES5 make my code work in Internet Explorer 11?
It converts the syntax, which is the part IE 11 cannot parse. Built-in objects and methods introduced after ES5, such as Promise, Map, Set, Symbol, Array.from, Object.assign or String.prototype.includes, are not added by the transpiler. The tool lists the ones it detects so you can include polyfills, for example from core-js, before your script.
What is loose mode?
Loose mode tells Babel to generate simpler, smaller and faster code that does not follow the specification in every edge case. For example, classes assign methods directly to the prototype (so they become enumerable) and spread uses concat. It is usually fine for application code but can change behavior in rare cases, so leave it off if you are unsure.
Why does the output start with functions like _classCallCheck or _createClass?
These are Babel helpers: small functions that implement features such as classes, spread, destructuring or async functions in ES5. Babel inlines each helper once at the top of the file. In larger projects you would normally share them with @babel/plugin-transform-runtime, but for a single converted file inlining keeps it self-contained.
How is async/await converted to ES5?
Babel rewrites async functions into generator functions and then converts generators into a state machine using an inlined regenerator runtime helper. The result still relies on Promise at run time, so older browsers need a Promise polyfill. The TypeScript fallback uses its own __awaiter and __generator helpers in the same way.
Is my code uploaded anywhere?
No. The Babel compiler is downloaded once from a public CDN and runs entirely in your browser. The code you paste and the files you open are processed locally and never sent to a server.
Can it convert BigInt or Proxy to ES5?
No. BigInt and Proxy need engine support and cannot be expressed in ES5 or fully polyfilled, so Babel leaves them as they are. The tool warns you when it detects them. Regular expression lookbehind and WeakRef have the same limitation.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.