JADX Scripts Guide
Jadx Scripts Guide
Prerequisites
- jadx with the
jadx-script-kotlinplugin installed (not bundled since latest versions — install from https://github.com/jadx-decompiler/jadx-script-kotlin) - Script files must use the
.jadx.ktsextension
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
- Add the script file to the project via
Add filesor right-click onInputs/Scripts→New script - The script appears under
Inputs/Scripts - Run options:
- Click
Runin the script editor toolbar - Reload the whole project (
F5orReloadtoolbar button) - Enable
File→Live reloadfor automatic reload on script file change
- Click
Execution Stages
Script code runs at different points depending on where it is placed:
| Location | When it runs | What is available |
|---|---|---|
| Top-level script body | Loading stage | Decompiler options (e.g. jadx.args) — classes not yet loaded |
jadx.afterLoad { } block | After classes are loaded | All class data, AST |
jadx.addPass / jadx.stages | During decompilation | Instruction-level data |
jadx.gui.ifAvailable { } block | Only in jadx-gui | GUI context, menu actions |
Available Wrapper API Sections
High-level wrapper methods on the script’s jadx instance:
| Section | Purpose |
|---|---|
rename | Rename classes, methods, and fields |
replace | Replace or modify instructions in methods |
stages | Execute custom code at specific decompilation stages |
search | Search for a class or method |
gui | Access jadx-gui UI features |
events | Receive or send jadx events (currently UI events only) |
decompile | Trigger class decompilation |
debug | View 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.