---
title: "JSR223 PreProcessor"
description: "Configure the JMeter JSR223 PreProcessor pre processors: properties, defaults, and practical usage notes for building reliable load tests."
url: https://docs.jmeter.ai/components/jsr223-preprocessor/
lastUpdated: 2026-10-01
source: docs.jmeter.ai
---

# JSR223 PreProcessor

*Part of the **Pre Processors** category. Also documented in context in the [full Component Reference](/user-manual/component-reference/#jsr223-preprocessor).*

**TL;DR:** the JSR223 PreProcessor runs Groovy code immediately before its parent sampler fires — the standard place to build a signed request, compute a timestamp-based header, or mutate a variable right before it’s used.

The JSR223 PreProcessor allows JSR223 script code to be applied before taking a sample.

| Name | Required | Description |
| --- | --- | --- |
| Name | No | Descriptive name for this element that is shown in the tree. |
| Language | Yes | The JSR223 language to be used |
| Parameters | No | Parameters to pass to the script.     The parameters are stored in the following variables:      - `Parameters` - string containing the parameters as a single variable - `args` - String array containing parameters, split on white-space |
| Script file | No | A file containing the script to run, if a relative file path is used, then it will be relative to directory referenced by “`user.dir`” System property |
| Script compilation caching | No | Unique String across Test Plan that JMeter will use to cache result of Script compilation if language used supports `[Compilable](https://docs.oracle.com/javase/8/docs/api/javax/script/Compilable.html)` interface (Groovy is one of these, java, beanshell and javascript are not)      :::note See note in JSR223 Sampler Java System property if you’re using Groovy without checking this option ::: |
| Script | Yes (unless script file is provided) | The script to run. |

The following JSR223 variables are set up for use by the script:

- `log` - ([Logger](https://www.slf4j.org/api/org/slf4j/Logger.html)) - can be used to write to the log file
- `Label` - the String Label
- `FileName` - the script file name (if any)
- `Parameters` - the parameters (as a String)
- `args` - the parameters as a String array (split on whitespace)
- `ctx` - ([JMeterContext](https://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterContext.html)) - gives access to the context
- `vars` - ([JMeterVariables](https://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterVariables.html)) - gives read/write access to variables:  `vars.get(key); vars.put(key,val); vars.putObject("OBJ1",new Object()); vars.getObject("OBJ2");`
- `props` - (JMeterProperties - class java.util.Properties) - e.g. `props.get("START.HMS");` `props.put("PROP1","1234");`
- `sampler` - ([Sampler](https://jmeter.apache.org/api/org/apache/jmeter/samplers/Sampler.html))- gives access to the current sampler
- `OUT` - System.out - e.g. `OUT.println("message")`

For details of all the methods available on each of the above variables, please check the Javadoc

### Common gotchas

- It runs **before** the sampler’s request is built from the JMeter GUI fields, but variable substitution in those fields happens at request-build time — so setting a JMeter variable here (`vars.put(...)`) and referencing it as `${myVar}` in the sampler works correctly.
- Scope matters: a PreProcessor attached directly to a sampler only runs for that sampler; one attached to a Thread Group or Controller runs before every sampler underneath it.
- Prefer Groovy over BeanShell for the same reason as the [JSR223 Sampler](/components/jsr223-sampler/) — BeanShell’s per-iteration interpretation cost adds up fast across thousands of iterations.
- Common use: computing an HMAC signature or JWT right before an [HTTP Request](/components/http-request/) that needs it in a header.

## Related

- [Correlation & Dynamic Values](/topics/correlation-dynamic-values/)
- [Regex Extractor Builder](/tools/regex-tester/)
- [JSR223 Groovy Scripting Guide](/topics/jsr223-groovy-scripting-guide/)
- [Full Component Reference](/user-manual/component-reference/)
- [Functions and Variables](/user-manual/functions/)
