JADX Scripts Guide

Jadx Scripts Guide

Prerequisites

Script File Naming

Scripts must be named with the .jadx.kts suffix, e.g. hello.jadx.kts.

Minimal Example

 1log.info { "Hello from jadx script!" }
 2
 3// get jadx decompiler script instance
 4val jadx = getJadxInstance()
 5
 6// adjust options if needed
 7jadx.args.isDeobfuscationOn = false
 8
 9// rename example
10jadx.rename.all { name ->
11    when (name) {
12        "HelloWorld" -> "HelloJadx"
13        else -> null
14    }
15}
16
17// run some code after loading is finished
18jadx.afterLoad {
19    log.info { "Loaded classes: ${jadx.classes.size}" }
20    // print class code
21    jadx.classes.firstOrNull()?.let { cls ->
22        log.info { "Class: '${cls.name}'" }
23        log.info { cls.code }
24    }
25}
26
27jadx.gui.ifAvailable {
28    // only executed when running inside jadx-gui
29    addMenuAction("Decompile All") {
30        jadx.decompile.allThreaded()
31    }
32}

Running Scripts

jadx-cli

Pass the script file alongside the input:

1jadx classes.dex hello.jadx.kts

jadx-gui

  1. Add the script file to the project via Add files or right-click on Inputs/ScriptsNew script
  2. The script appears under Inputs/Scripts
  3. Run options:
    • Click Run in the script editor toolbar
    • Reload the whole project (F5 or Reload toolbar button)
    • Enable FileLive reload for automatic reload on script file change

Execution Stages

Script code runs at different points depending on where it is placed:

LocationWhen it runsWhat is available
Top-level script bodyLoading stageDecompiler options (e.g. jadx.args) — classes not yet loaded
jadx.afterLoad { } blockAfter classes are loadedAll class data, AST
jadx.addPass / jadx.stagesDuring decompilationInstruction-level data
jadx.gui.ifAvailable { } blockOnly in jadx-guiGUI context, menu actions

Available Wrapper API Sections

High-level wrapper methods on the script’s jadx instance:

SectionPurpose
renameRename classes, methods, and fields
replaceReplace or modify instructions in methods
stagesExecute custom code at specific decompilation stages
searchSearch for a class or method
guiAccess jadx-gui UI features
eventsReceive or send jadx events (currently UI events only)
decompileTrigger class decompilation
debugView or access internal jadx data structures

Source reference for wrapper implementation: jadx-plugins/jadx-script-kotlin/src/main/kotlin/jadx/plugins/script/kotlin/runtime/ScriptRuntime.kt (line 41+)

Accessing Internals

jadx.internalDecompiler exposes the underlying jadx decompiler object (same API as the jadx library mode). Use only when no high-level wrapper exists for the required data. Opening an issue to request a proper wrapper is preferred over relying on this field.