JXA (JavaScript for Automation)

JXA is one of those things that Apple designed broken–and then apparently left to rot. Whereas was maintained and updated for decades, JXA was apparently a one-off that never got a lot of attention, and yet it seems to be the only remaining halfway decent way to automate macOS from the command line (no, Shortcuts doesn’t count, and has been crippled by the removal of as a supported scripting language).

Oddly enough, for something purporting to be focused on automation, the thing can’t even handle basic things like performing HTTP requests directly (although you can massage the Objective-C bridge to sort of do it), and the documentation is a mess.

But every now and then I try to make sense of it, and this time around (early 2024, with macOS Sonoma as the current release) I’m going to document my findings here:


Category Date Link Notes
Reference 2021 JXA Wiki

A collection of JXA examples

Keyboard Maestro Forum

Quite a few lost snippets of osascript/JXA invocation

Notes on automating macOS using Javascript (JXA)

A gist with a few more references

JS OSX App Examples

A collection of JXA examples, as .scpt files

Vincent's Productivity Suite for Alfred

A collection of Alfred workflows that have quite a few JAX examples

Persistent JXA

A blog post that led me to PersistentJXA, which has more examples

2024 JXA Cookbook

A collection of JXA examples

The Unexpected Return of JavaScript for Automation

Some examples of Objective-C bridging

Keyboard Maestro Wiki

A collection of JXA examples