🌐
ES6 to ES5 Converter
es6-to-es5.vercel.app
ES6 to ES5 Converter | Free Online JavaScript Transpiler & Minifier
Convert ES6/ES2015+ JavaScript code to ES5 instantly. Free online transpiler with minification, deep minify, and browser compatibility features. Includes tutorials and guides on JavaScript transpilation. No signup required!
🌐
GitHub
github.com β€Ί lebab β€Ί lebab
GitHub - lebab/lebab: Turn your ES5 code into readable ES6. Lebab does the opposite of what Babel does. Β· GitHub
Lebab transpiles your ES5 code to ES6/ES7. It does exactly the opposite of what Babel does.
Starred by 5.6K users
Forked by 151 users
Languages Β  JavaScript
🌐
Jsontotable
jsontotable.org β€Ί es5-to-es6-converter
ES5 to ES6 Converter - Free Online Tool | Modernize JavaScript Code | JSON to Table Converter
Convert ES5 JavaScript to modern ES6+ syntax online. Free tool to upgrade legacy JavaScript code with arrow functions, let/const, and modern features.
🌐
Gitlab
jstool.gitlab.io β€Ί babel-es6-to-es5
ES6 conversion ES5 (Babel.js online test) js escape js new syntax compatible with old browsers
ES6 converts ES5, also supports ES7/ES8/ES9, etc. ... Online use, simple and lightweight, no need to install Node.js, configure a complex development environment
🌐
CodeSandbox
codesandbox.io β€Ί p β€Ί sandbox β€Ί convert-es6-to-es5-with-babel-z0cq1
Convert-ES6-to-ES5-with-babel
CodeSandbox is a cloud development platform that empowers developers to code, collaborate and ship projects of any size from any device in record time.
🌐
Esnext
esnext.github.io β€Ί es6-module-transpiler β€Ί editor
ES6 Module Transpiler β€” Online Editor
ES6 Module Transpiler is a JavaScript library for converting JavaScript files written using the ES6 draft specification module syntax for use in existing JavaScript environments. Try out the online editor demo to see it in action.
Find elsewhere
🌐
Gitlab
jstool.gitlab.io β€Ί es6-to-es5-converter
ES6+ to ES5 converter, JS Syntax Converter - Online Babel.js compiler - Online ES6/ES7/ES8 to ES5 Conversion for Legacy Browser Compatibility
Online Babel.js compiler - Convert JavaScript modern syntax to legacy syntax (ES5) for legacy browser compatibility ... Import folders, batch convert js files, download zip and extract to maintain original file tree and path structure Β· Solve ES6, ES7, ES8 and other new syntax browser error problems
🌐
Quora
quora.com β€Ί Is-there-any-compiler-to-convert-the-code-from-ES5-to-ES6
Is there any compiler to convert the code from ES5 to ES6? - Quora
Answer (1 of 3): Lebab [1] was designed to do this. You can try it out online. Once you’ve run it through Lebab you may want to run it through Prettier [2] for readability. Prettier also has an online playground. 1. GitHub - uniibu/lebab-ce: Lebab - Community Editor 2. Prettier Β· Opinionated ...
🌐
Stack Overflow
stackoverflow.com β€Ί questions β€Ί 54584346 β€Ί convert-es6-javascript-to-es5-format
json - Convert ES6 JavaScript to ES5 format - Stack Overflow
There is a code snippet found in other questions but how can I convert that to ES5 format. Trying to get data from JSON array. const match = (query, input) => input.filter((entry) => Object.entries(query).every(([k, v]) => entry[k] === v)); ... Hi Joe. Please have a look at the how to ask for StackOverflow. Typically questions like this one will get closed as too broad. ... There are many good online ES6 to ES5 transpilers.
Top answer
1 of 4
9

The best idea is to go into the source code of Lebab

Open bin/file.js. Read all the lines to understand that script.

The interesting part is the following:

  var transformer = new Transformer({transformers: transformers});
  transformer.readFile(file[0]);
  transformer.applyTransformations();
  transformer.writeFile(program.outFile);

More specificaly transformer.applyTransformations();

Let's open /src/transformer.js

In this file I see some usefull functions :

  /**
   * Prepare an abstract syntax tree for given code in string
   *
   * @param string
   */
  read(string) {

    this.ast = astGenerator.read(string, this.options);

  }

So you can use the transformer with a string of code (not a file)

Now you can apply the transformations "ES5 to ES6"

  /**
   * Apply All transformations
   */
  applyTransformations() {

    for (let i = 0; i < this.transformations.length; i++) {
      let transformation = this.transformations[i];
      this.applyTransformation(transformation);

    }

And then, recast it into string

  out() {
    let result = recast.print(this.ast).code;

    if(this.options.formatter) {
      result = formatter.format(result, this.options.formatter);
    }

    return result;
  }

Summary

var transformer = new Transformer({});
transformer.read('var mySourceCode = "in ES5"');
transformer.applyTransformations();
console.log(transformer.out());

JSFiddle demo here

If you don't want all transformations, you can choose what you want with options:

var transformers = {
  classes: false,
  stringTemplates: false,
  arrowFunctions: true,
  let: false,
  defaultArguments: false,
  objectMethods: false,
  objectShorthands: false,
  noStrict: false,
  importCommonjs: false,
  exportCommonjs: false,
};

var transformer = new Transformer({transformers: transformers});

JSFiddle demo with options

2 of 4
5

To change ES5 to ES6 you can use this https://www.npmjs.com/package/xto6

You have to install it

npm install -g xto6

And then just:

xto6 es5.js -o es6.js

There is also gulp plugin https://www.npmjs.com/package/gulp-xto6:

var gulp = require('gulp');
var xto6 = require('gulp-xto6');

gulp.task('default', function () {
  return gulp.src('path/to/fixtures/es5/*.js')
    .pipe(xto6())
    .pipe(gulp.dest('path/to/fixtures/es6/'));
});
🌐
Hexmos
hexmos.com β€Ί freedevtools β€Ί tldr β€Ί common β€Ί babel
Transpile JavaScript - Babel ES6 to ES5 | Online Free DevTools by Hexmos
Transpile JavaScript code with Babel. Convert ES6/ES7 syntax to ES5 for broader browser compatibility. Free online tool, no registration required.
🌐
Jsontotable
jsontotable.org β€Ί javascript-transpiler
JavaScript Transpiler - Free Online Tool | Transpile ES6+ to ES5 | JSON to Table Converter
Free online JavaScript transpiler to convert modern ES6+ code to ES5 for maximum browser compatibility.
🌐
ES6 to ES5 Converter
es6-to-es5.vercel.app β€Ί blog β€Ί what-is-es6-and-why-convert-to-es5
What is ES6 and Why Convert to ES5? | ES6 to ES5 Online Converter
January 15, 2025 - Complete step-by-step tutorial on converting ES6 JavaScript code to ES5 using our online tool.
🌐
HTML5 Game Devs
html5gamedevs.com β€Ί html5 game coding β€Ί coding and game design
best way to convert ES6 syntax to ES5 ?
August 18, 2018 - hi, i have start my project with ES6 syntax, but for exporting to cocoon.io in canvas mode it must be ES5 syntax. What's the easier way to do that ? (i have try with babeljs but without success) if not i rewrite all with ES5 syntax but it's not convenient.... Another question why coding in Es6......
🌐
David Walsh
davidwalsh.name β€Ί lebab
ES5 to ES6 with Lebab
March 1, 2017 - Convert legacy ES5 JavaScript to ES6/ESNext with command line and Node.js utility Lebab, much like Babel.