Home › Developer Tools › ES6 to ES5 Converter

ES6 to ES5 Converter

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

  1. 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.
  2. Pick the target browsers. "Internet Explorer 11" produces plain ES5; newer targets keep the syntax those browsers already support.
  3. Choose a module format if your code uses import or export: CommonJS for Node and bundlers, AMD or UMD for script loaders.
  4. Press Convert to ES5 (or keep Convert as I type on). Fix any syntax error shown in red.
  5. 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 featureAdded inExampleES5 equivalent produced
let / constES2015const x = 1;var x = 1; (renamed if needed to keep block scope)
Arrow functionsES2015a => a * 2function (a) { return a * 2; }, with this captured in _this
Template literalsES2015`Hi ${name}`"Hi ".concat(name)
ClassesES2015class A extends B {}Constructor functions plus _classCallCheck, _createClass, _inherits helpers
Destructuring and defaultsES2015function f({ a = 1 } = {})Temporary variables and arguments checks
Spread / restES2015 / ES2018[...a, b][].concat(_toConsumableArray(a), [b])
for…ofES2015for (const x of list)Iterator helper with an array fast path
Exponent operatorES20162 ** 10Math.pow(2, 10)
async / awaitES2017await fetchData()Generator state machine via the regenerator helper (needs Promise)
Optional chaining / nullishES2020a?.b ?? cExplicit === null || === void 0 checks
Class fields and #privateES2022static 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.

Related tools

TypeScript to JavaScriptConvert TypeScript or TSX to clean JavaScript instantly: strip types, keep or compile JSX.JavaScript MinifierMinify JavaScript with Terser: compress, mangle and see how many bytes you save.JavaScript BeautifierFormat and beautify messy or minified JavaScript, or minify it.JavaScript Syntax CheckerCheck JavaScript for syntax errors with line and column, for any ES version, script or module.JSON to Excel ConverterTurn JSON into a styled .xlsx spreadsheet; nested arrays become their own linked sheets.JSON to CSVConvert JSON data to CSV for spreadsheets.CSV to JSONConvert CSV data to JSON with live preview.Excel to CSVConvert XLSX spreadsheets to CSV.CSV ViewerOpen a CSV or TSV file as a sortable, filterable table.Excel Viewer (XLSX / XLS)Open XLSX, XLS and ODS spreadsheets in your browser without Excel.Line Ending ConverterConvert text and files between CRLF, LF and CR line endings.Markdown to HTMLConvert Markdown to clean HTML with a live editor.XML to JSONConvert XML to JSON with validation.Text Encoding ConverterDetect and convert text file encodings like UTF-8, UTF-16 and Latin-1.JSON ViewerExplore JSON as a collapsible tree, search keys and values and copy any node's path.TTF to WOFF2 ConverterConvert TTF and OTF fonts to WOFF2 or WOFF and get a ready @font-face CSS snippet.Chmod CalculatorConvert Linux file permissions between checkboxes, octal (755) and symbolic (rwxr-xr-x) notation.JSON to TypeScriptGenerate TypeScript interfaces or types from JSON, with nested types and optional fields.Morse Code TranslatorTranslate text to Morse code and back, then play it as sound or a blinking light, or save a WAV.HTML Table GeneratorBuild HTML tables in an editable grid with styles, header rows, CSV import and live preview.Hex to Text ConverterConvert hex to text and text to hex with UTF-8 support and space, 0x, \x or comma formats.JSON to XML ConverterConvert JSON to well-formed XML with attributes, arrays and pretty print.JSON to YAML ConverterConvert JSON to clean YAML as you type, with indent, quoting and sort options.YAML to JSON ConverterConvert YAML to pretty or minified JSON, with errors pinned to the exact line.HTML to Markdown ConverterTurn HTML or pasted rich text into clean Markdown with tables and live preview.Markdown Table GeneratorBuild Markdown tables in a grid or paste from Excel/CSV, with alignment and preview.JSON ValidatorCheck JSON with the exact line and column of each error, fix tips and one-click auto-fix.Image to Base64Convert images to Base64 data URIs, CSS backgrounds and HTML img tags in your browser.Base64 to ImagePaste a Base64 string or data URI to preview, identify and download the image.JSON CompareCompare two JSON documents and see every added, removed and changed path.Hex to DecimalConvert hex to decimal instantly with steps and signed mode.Decimal to HexConvert decimal to hex instantly with steps and signed mode.Binary to DecimalConvert binary to decimal instantly with steps and signed mode.Decimal to BinaryConvert decimal to binary instantly with steps and signed mode.Two's Complement CalculatorDecimal to two's complement binary and back for 4-64 bits, with invert-and-add-1 steps.XML to CSV ConverterConvert XML to CSV: detects repeating records, flattens nested data, pick your columns.CSV to XML ConverterConvert CSV to well-formed XML with custom root and row names, escaping and pretty print.TOML to JSON ConverterConvert TOML to JSON and JSON to TOML with a full v1.0 parser and clear error lines.CSV to YAML ConverterConvert CSV rows to a YAML list of mappings with type inference and delimiter detection.Endianness ConverterSwap byte order of 16, 32 and 64-bit hex values and see big- and little-endian integers and floats.Excel to SQL ConverterTurn an Excel sheet into CREATE TABLE and INSERT statements for MySQL, PostgreSQL, SQLite or SQL Server.Excel to VCF ConverterTurn an Excel contact list into a vCard .vcf file for iPhone, Android, Google or Outlook.File to C ArrayConvert any file into a C or C++ byte array header, like xxd -i, with const and PROGMEM options.Image to C ArrayConvert images to monochrome, RGB565 or RGB888 C arrays for OLED, LCD and TFT displays.JSON Merge ToolDeep-merge two or more JSON objects with array concat, replace or union and a conflict rule.JSONL to CSV ConverterConvert JSON Lines / NDJSON to CSV with flattened columns; streams large files locally.PHP Unserialize OnlineDecode PHP serialize() strings to JSON, a tree or print_r, and serialize JSON back to PHP.SQL Dialect ConverterTranslate SQL between MySQL, PostgreSQL, SQLite, SQL Server, Oracle, BigQuery and more.TSV to JSON ConverterTurn tab-separated data pasted from Excel or Sheets into a JSON array or keyed object.XLS to XLSX ConverterConvert old Excel 97-2003 .xls workbooks to modern .xlsx files in your browser, several at once.XML to Excel ConverterTurn repeating XML elements into an .xlsx spreadsheet with attributes and nested data as columns.XSD to XML Sample GeneratorGenerate a sample XML document from an XSD schema, with types, attributes and namespaces.YAML to CSV ConverterTurn a YAML list of objects into CSV with dot-notation columns, custom column order and download.DOCX to Markdown ConverterConvert Word .docx to clean Markdown with headings, lists, tables, links and images in a ZIP.JavaScript Object to JSONTurn JS object literals and Python dicts into valid JSON: quotes keys, fixes commas and values.JSON Graph VisualizerSee JSON as an interactive node graph with zoom, collapse and search; export PNG or SVG.KML ViewerOpen KML and KMZ files on an interactive map: placemarks, paths, polygons, folders, export.MySQL to PostgreSQL ConverterConvert MySQL dumps and CREATE TABLE statements to PostgreSQL: types, AUTO_INCREMENT, ENUMs, quotes.Text to CSV ConverterTurn space-aligned, fixed-width, pipe or tab separated text into clean CSV with a live preview.VCF File ViewerOpen vCard .vcf files as contact cards with photos, search and duplicate check, export CSV.XML ViewerBrowse XML as a collapsible tree with search, XPath of any node, attributes and big-file support.JSON to Go StructTurn JSON into Go structs with inferred types, nested structs and json tags.JSON to Python ClassGenerate Python dataclasses, Pydantic models or TypedDicts with type hints from JSON.JSON to C# ClassConvert JSON to C# classes or records with System.Text.Json or Newtonsoft attributes.JSON SorterSort JSON keys A-Z recursively, sort arrays by value or by a key, then pretty-print or minify.JSON to HTML TableConvert a JSON array of objects into clean HTML table code with CSS styles and a live preview.CSV to SQL ConverterConvert CSV to SQL CREATE TABLE and INSERT statements for MySQL, PostgreSQL, SQLite or SQL Server.IPv4 to IPv6 ConverterConvert IPv4 to IPv4-mapped, 6to4 and NAT64 IPv6, extract IPv4 from IPv6, and get int/hex/binary.
See all 129 Data & File Format Converters →