Skip to content

Jadx scripts guide

skylot edited this page Mar 31, 2026 · 4 revisions

Jadx Scripts guide

Jadx uses Kotlin to support scripting.

Note

In latest jadx version script support moved into external plugin and not bundled with jadx, check this page for installation details.

Simple jadx script: hello.jadx.kts

log.info { "Hello from jadx script!" }

// get jadx decompiler script instance
val jadx = getJadxInstance()

// adjust options if needed
jadx.args.isDeobfuscationOn = false

// rename example
jadx.rename.all { name ->
    when (name) {
        "HelloWorld" -> "HelloJadx"
        else -> null
    }
}

// run some code after loading is finished
jadx.afterLoad {
    log.info { "Loaded classes: ${jadx.classes.size}" }
    // print class code
    jadx.classes.firstOrNull()?.let { cls ->
        log.info { "Class: '${cls.name}'" }
        log.info { cls.code }
    }
}

jadx.gui.ifAvailable {
    // if a script is running in jadx-gui, 
    // we can add menu entry to run custom code
    addMenuAction("Decompile All") {
        jadx.decompile.allThreaded()
    }
}

Warning

Script file name should end with .jadx.kts

Examples

Check script examples in examples

Script usage

In jadx-cli

Add script file as input:

jadx classes.dex hello.jadx.kts

In jadx-gui

  1. Add script file to the project (using Add files or right-click menu on Inputs/Scripts and select New script)
  2. Script will appear in Inputs/Scripts section
  3. After script change, you can run it using Run button in script editor toolbar or reload whole project (Reload button in toolbar or F5). Also, you can enable Live reload option in File menu to reload a project automatically on script change

Execution time

Each part of jadx script is executed at different time or stages.
Script base code loaded and evaluated at the loading stage, at this point classes info is not yet loaded, but it is possible to change loading options.
If you need to process already loaded classes, code to do so should be placed in jadx.afterLoad block.
Also, to execute during decompilation you can use jadx.addPass or use utility methods in jadx.stages

Available methods

For simplify usage of jadx API in scripts, wrapper methods were added and divided into next sections:

  • rename - to rename any classes, methods, fields
  • replace - replace/change instructions in methods
  • stages - execute custom code at different decompilation stages
  • search - search class or method
  • gui - methods to access jadx-gui UI
  • events - receive or send jadx events (only UI events for now)
  • decompile - run classes decompilation
  • debug - utility methods used to view/access internal information

For more details, check the source code here.

Internal info

Now jadx.internalDecompiler can be used to access data in jadx decompiler (same as in Use jadx as a library.
This can be useful if this is no other way to access some jadx data, but it is suggested to not use this field.
Please feel free to open an issue if you still need to use jadx.internalDecompiler.

Clone this wiki locally