How to Transpile JavaScript - Step by Step Guide
Input Your Modern JavaScript
Start with your modern JavaScript code. You can:
Example: Modern ES6+ Input
A few lines of ES6: const, an arrow function, a template literal and shorthand properties.
const name = "Ada";
const greet = (who) => `Hello, ${who}!`;
const user = { name, greet };What Gets Converted
The output updates as you type. Four kinds of syntax are rewritten, each only where ES5 gives the same result:
Example: The Same Code as ES5
This is exactly what the page produces for the example above:
var name = "Ada";
var greet = function (who) { return "Hello, ".concat(who, "!"); };
var user = { name: name, greet: greet };Read the Note Above the Output
The note tells you how far the conversion got:
Export Transpiled Code
Take the result with you:
Frequently Asked Questions
What does this transpiler actually change?
Four kinds of syntax. let and const become var, arrow functions become function expressions (with .bind(this) added when the arrow reads this), template literals become plain strings joined with .concat(), and shorthand like { name } or { greet() {} } is written out as name: name and greet: function () {}. Each change is made in place in your own text, so everything else stays exactly where you put it.
Why is some ES6 code still in the output?
Classes, async/await, generators, destructuring, spread, default parameters, for...of, modules, optional chaining and the like can't be rewritten as a one-for-one swap; a real compiler such as Babel adds helper functions and sometimes a runtime library for them. Rather than produce something that looks like ES5 but behaves differently, the page leaves them as written and lists each one with its line number above the output. If that list is empty, the badge says ES5.
Why did a let or const stay as it is?
Because var would change how the code runs. The common case is for (let i = 0; ...) with callbacks inside the loop: every callback gets its own i with let, but they would all share one with var. A let is also kept when the same name is declared twice in the function, when a let without a starting value sits inside a loop, or when hoisting a var would hide a variable of the same name from outside. Those lines show up in the list above the output.
Will the output behave exactly like my original code?
That is the rule every change follows. Arrows that use arguments or super are left alone, since a function expression would see different values. Template literals become "text".concat(value), which turns values into text the same way a template does. Your strings, comments, regular expressions and numbers are never touched, so a long ID like 8901240544102066246, a zip code "00501" or a price written 14.50 come out character for character. Still, run your tests on the result before you ship it.
What happens if my code has an error?
You get the line and column of the problem with the line shown and a marker under the spot, and no output. If you pasted JSON, TypeScript or JSX by mistake, the message says so and points you to the right converter instead.
Do I still need polyfills?
Often, yes. This page only changes syntax. Built-ins added in ES6 and later, such as Promise, Map, Set, Array.from, Object.assign or String.prototype.includes, don't exist in very old browsers like Internet Explorer 11, and no syntax change can add them. Load a polyfill for the ones your code uses.
Is my code uploaded anywhere?
No. Parsing and converting happen in your browser, and nothing you paste or upload is sent to our server. Reload the page and the editor starts empty.
Going the other way? The ES5 to ES6 converter modernizes old code, and the JavaScript compressor shrinks the result for production.