Access macOS JavaScript for Automation APIs directly in node
Clone or download
Latest commit 4b1e256 Apr 24, 2017
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Rewrite to use osa2 for interfacing with macOS Apr 23, 2017 s/OS X/macOS/g Apr 23, 2017
index.js Move TODO comment to a more relevant line Apr 23, 2017
jxa-node.js Create a repl that exposes Application() globally May 29, 2016
package.json Write simple tests Apr 23, 2017
test.js Write simple tests Apr 23, 2017
yarn.lock Write simple tests Apr 23, 2017


Access macOS JavaScript for Automation APIs directly in node

Similar to the osa2 module, but with synchronous calls and an API with a bit more 'magic'. If you're building a library, use osa2. This module is best suited for small scripts.


Module: npm install --save jxa

REPL: npm install -g jxa


Interact with apps in the same way you would with Apple's official JavaScript for automation runtime, as described here. The only difference is that you must get a handle to the Application object by requiring this module.

var Application = require('jxa').Application;

var iTunes = Application('iTunes');

var name   =;
var artist = iTunes.currentTrack.artist();

console.log(name + ' by ' + artist);
// Pay No Mind (feat. Passion Pit) by Madeon

// Music pauses;
// Music plays

If you install JXA globally (npm install -g jxa) a REPL is provided that exposes Application() in the global scope.

will@laptop ~ $ jxa-node
> Application('iTunes')
[object JXAReference => [object Application]]
> Application('iTunes').play()
> Application('iTunes').currentTrack
[object JXAReference => [object ObjectSpecifier]]
> Application('iTunes')
'No Problem (feat. Lil Wayne & 2 Chainz)'