When does Babel output need formatting?
Babel-emitted code is normally invisible — your build pipeline runs it through Webpack/Rollup/Vite which then minifies it. You see raw Babel output when (1) sourcemaps fail to load and DevTools shows the compiled file, (2) you intentionally inspect the dist/ output to debug a transpilation difference, (3) you fork a transpiled package from node_modules and need to read it, or (4) you compare what two Babel preset configurations emit. In each case, formatting the dense single-line output makes it scannable.
Why not just use source maps instead?
Source maps are the right answer when they work — but they often do not. A common scenario: a third-party package shipped without source maps, or the maps were stripped by a server. Another: source-map-loader silently dropped a map because it pointed to a missing file. When you have to read the compiled JavaScript directly, formatting it is the only way. Babel-formatted output also reveals exactly what the transpiler did, which source maps hide by design.
Will this format Babel's helper functions correctly?
Yes. Babel emits helpers like _interopRequireDefault, _interopRequireWildcard, _classCallCheck, _slicedToArray, _toConsumableArray, _asyncToGenerator, and many others. They are normal functions that look ugly only because they are emitted as one line each. The formatter restores braces, semicolons, and indentation so the helper logic becomes readable.
Can it format async/await transpiled to generators?
Yes. The async-to-generator transform produces a regeneratorRuntime.wrap(...) call wrapping a switch over numeric states. The output is verbose but uses ordinary JavaScript control flow. After formatting you see the case 0 / case 1 / case "end" structure that maps back to your original await points, plus the _context.next, _context.sent, _context.done bookkeeping the runtime uses.
Does it preserve "use strict" directives and module headers?
Yes. The formatter is whitespace-only — it never removes or moves directives, module headers, or comments. Babel-emitted output typically begins with "use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nexports.default = void 0; — these stay at the top, formatted onto separate readable lines.
How does it differ from formatting raw modern JavaScript?
Babel output is functionally identical to ordinary ES5 — it uses var, function expressions, switch statements, and object literals. The formatter applies the same brace/semicolon rules. The difference is what you see: dense one-line module headers, helper imports at the top, _interopRequireDefault wrappers around every CommonJS require, and getters/setters using Object.defineProperty instead of class syntax. Reading transpiled output is a learnable skill — formatting makes it readable.
Will it work with Babel's loose mode and esmodules output?
Yes. Loose mode emits less spec-compliant but smaller output (a class becomes a constructor function plus prototype assignments instead of going through _classCallCheck and _createClass helpers). The esmodules target preserves import/export syntax and skips most helpers. Both produce valid JavaScript that the formatter handles. The output looks closer to the source for esmodules and closer to ES5 for loose-with-CommonJS.
Is the Babel output I paste sent to your servers?
No. Formatting runs entirely in your browser using JavaScript. Compiled bundles often contain embedded API endpoints, internal-only feature names, customer identifiers, and proprietary algorithms — none of that leaves the device. Open DevTools → Network and click Format to verify no requests are made.