Getting started with ImageJ1 macros

Many people are asking here in how to start working with macros.

The questions are often related to specific use cases.

Besides their specific details, the beginners’ questions are mostly about basic handling and basic operations of macros, such as

  • loop over files in a folder
  • loop over pixels
  • working with RoiManager or ResultsTable etc.

To avoid duplication, all relevant answers to general macro issues can be collected here to create a reusable reference.

(In this sense all contributors are asked to keep this post as clear and structured as possible. Here should be not the place for specific discussions.)

Dear Macro-Beginner,

The ImageJ macro language is a very powerful tool to automate your work with ImageJ/FIJI or to create customized commands for your recurrent work.

Because of the huge capabilities of the macro language the information and instructions can be overwhelming. :anguished:

Don’t worry! :grinning:
Getting started is not rocket science – once you found a good entry.

Your places to start

Place I to start is the \macro folder in your ImageJ/FIJI installation.
There you can find dozens of macros which can be used as examples or templates. And with a bit luck you will find something close to your needs.
All these macros can also be found on the ImageJ website under:

Place II to start is the list of Built-in Macro Functions:

Place III to start is the ImageJ Macro Language Programmer’s Reference Guide:

Place IV to start is a good Introduction into Macro Programming:

… more info to come …


Hey @phaub,

great initiative! Let me just add some shameless self-advertisement



Let me add a few important resources (in my opinion):

Although more general, the user guides also deal with the macro language quite a bit:


1 Like