LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

decaffeinate

convert CoffeeScript to modern JavaScript

TLDR

Convert a CoffeeScript file to JavaScript
$ decaffeinate [file.coffee]
copy
Convert using CoffeeScript 2 compatibility
$ decaffeinate --use-cs2 [file.coffee]
copy
Convert and use ES module syntax (import/export)
$ decaffeinate --use-js-modules [file.coffee]
copy
Write output to a specific file
$ decaffeinate -o [output.js] [file.coffee]
copy
Convert multiple files at once
$ decaffeinate [file1.coffee] [file2.coffee]
copy
Use loose mode for simpler output
$ decaffeinate --loose [file.coffee]
copy

SYNOPSIS

decaffeinate [options] files...

DESCRIPTION

decaffeinate converts CoffeeScript to modern JavaScript (ES6+). It produces idiomatic JavaScript with proper class syntax, arrow functions, template literals, and destructuring.Useful for migrating CoffeeScript codebases to JavaScript.

PARAMETERS

-o, --output file

Write output to the specified file path.
--use-cs2
Treat input as CoffeeScript 2 code (default assumes CoffeeScript 1).
--use-js-modules
Convert `require`/`module.exports` to ES6 `import`/`export` syntax.
--modernize-js
Treat the input as JavaScript and apply only JS-to-JS transforms (no CoffeeScript conversion).
--literate
Treat input as Literate CoffeeScript.
--loose
Enable all loose transformation options for simpler output (may have minor semantic differences).
--prefer-let
Use `let` instead of `const` for most variables in the output.
--disable-suggestion-comment
Omit the followup suggestions comment at the top of the output file.
--optional-chaining
Use JavaScript optional chaining (`?.`) in generated output.
--nullish-coalescing
Use the nullish coalescing operator (`??`) in generated output.
--logical-assignment
Use ES2021 logical assignment operators (`&&=`, `||=`, `??=`).
--disable-babel-constructor-workaround
Disable Babel class constructor workaround.

CAVEATS

Some CoffeeScript patterns may require manual cleanup. Review generated code for edge cases.

SEE ALSO

coffee(1), babel(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid