Skip to content

Create a JMeter Script with Claude AI: Correlation and Parameterization, Step by Step

Here is a situation most of us know. You have two days to script a login and checkout flow in JMeter, and the app has CSRF tokens, session IDs and a dynamic order ID in every other request. The question everyone asks now is simple: "Can ChatGPT or Claude just do this for me?"

Short answer: it can do most of the boring part. It cannot replace your judgment. In this post I will show you exactly how I use Claude (the same steps work with ChatGPT, Gemini or Grok) to build a JMeter script with correlation and parameterization, and where you still need to check its work.

This is the first post in a new series on this blog, AI in Performance Testing. Every day I will share one practical way to use AI tools in real performance testing work.

Workflow: record the flow as a HAR file, give it to Claude, get a JMX script, verify it in JMeterFrom browser recording to a working JMeter scriptYou recordthe user flowsave as HARflow.har (cleaned)paste + promptClaude / ChatGPTreturnsscript.jmxyou verifyJMeter1 user firstfix what the AI missedremove passwords + cookies
The AI does the boring part. You still own the verification.

What you need before you start

  • Apache JMeter 5.6 or later installed.
  • Access to Claude, ChatGPT, Gemini or any similar AI chat tool.
  • Chrome or Edge, to record the user flow.
  • A test environment. Never record against production with real customer accounts.

Step 1: Record the flow and save it as a HAR file

A HAR file is a recording of every request your browser made: URL, headers, body and the full response. This is exactly what the AI needs to understand your flow.

  1. Open Chrome, press F12 and go to the Network tab.
  2. Tick Preserve log so the recording survives page redirects.
  3. Do the business flow once: open the home page, log in, search, add to cart, check out, log out.
  4. Right-click any request and choose Save all as HAR with content.

Important: a HAR file contains your password, cookies and tokens in plain text. Before you paste it into any AI tool, replace the real password with something like Test@123, and remove Cookie and Authorization header values. If your company does not allow test data in public AI tools, use your company's approved AI tool instead.

HAR files get big. If yours is more than a few MB, filter the Network tab to Fetch/XHR and Doc before saving, so you skip images, fonts and CSS. JMeter does not need them for a protocol-level test anyway.

Step 2: Ask the AI to find the dynamic values

Do not ask for the full script straight away. First ask it to find the values that change on every run. This is the real correlation work, and doing it as a separate step gives much better results.

I am building a JMeter load test. Attached is a HAR file of a login
and checkout flow (passwords and cookies removed).

1. List every value that the server generates and the browser sends
   back in a later request (tokens, session ids, order ids, view state).
2. For each one, tell me:
   - which response it first appears in
   - which later requests use it
   - the best JMeter extractor to capture it (JSON Extractor,
     Regular Expression Extractor or Boundary Extractor) and the
     exact expression
3. List values that look dynamic but are actually static.
Show the result as a table.

For a typical login and checkout flow, Claude finds the CSRF token in the login page HTML, a sessionId in a JSON response, and the orderId returned after checkout. It will also tell you when something like a version=3.2.1 parameter is static, which saves you from correlating something that never changes.

Correlation: capture the csrf token from the first response and send it in the next requestCorrelation in one pictureGET /loginRequest 1response HTMLname="_csrf" value="a8f3c1..."extractRegex Extractorsaves it as ${csrfToken}reusePOST /loginRequest 2_csrf=${csrfToken}fresh value every timeno more 403 errors
A value the server generates must be captured and sent back, not hard-coded.

Step 3: Ask for the script with extractors and test data

Now ask for the JMX file. Be specific about how you want it built. A vague prompt gives you a vague script.

Now generate a JMeter 5.6 .jmx test plan for this flow:
- One Thread Group, 1 user, 1 loop (I will add load later)
- HTTP Request Defaults with the server name, and a Cookie Manager
- One Transaction Controller per business step, named
  T01_Home, T02_Login, T03_Search, T04_AddToCart, T05_Checkout
- Add the extractors from your table, with default value NOT_FOUND
- Read username and password from users.csv with a CSV Data Set Config
- Add a Response Assertion on each step for text that proves the page loaded
- Use only built-in JMeter elements, no third-party plugins
Return the full .jmx file.

Copy the answer into a file named checkout.jmx and open it in JMeter. For a CSRF token in HTML, the Regular Expression Extractor it creates will look like this:

Name of created variable : csrfToken
Regular expression       : name="_csrf" value="(.+?)"
Template                 : $1$
Match No.                : 1
Default value            : NOT_FOUND

And for a value inside a JSON response, a JSON Extractor:

Names of created variables : sessionId
JSON Path expressions       : $.data.sessionId
Match No.                   : 1
Default values              : NOT_FOUND

In the next request, the hard-coded value is replaced with ${csrfToken} or ${sessionId}. That is correlation done.

Step 4: Parameterize the test data

If 100 virtual users all log in as the same user, you are not testing anything real. Sessions clash, caches look better than they are, and some apps lock the account. Ask the AI to create a users.csv template and wire it in:

username,password
perfuser01,Test@123
perfuser02,Test@123
perfuser03,Test@123
Parameterization with a CSV Data Set Config: each JMeter thread reads a different row of users.csvParameterization: every virtual user gets its own datausers.csvusername,passworduser01,Test@123user02,Test@123user03,Test@123read row by rowCSV Data Set Config${username} ${password}user01user02user03
Same script, different data for every thread.

You can also ask it for other test data ideas: random search keywords from a CSV, ${__Random(1,5)} for quantity, or ${__time(yyyyMMddHHmmss)} to build unique order references.

Step 5: Verify before you add load

This is the step people skip, and it is the one that matters most. AI-generated scripts usually look correct. Sometimes they are not. The common mistakes to look for:

  • A regex boundary that matches the wrong occurrence of a token.
  • A value that needs URL encoding (for example a token with + or /) sent without encoding.
  • A token hidden in a response header, which the AI missed because it only read the body.
  • An element or property name that does not exist in your JMeter version.
Checklist to verify an AI generated JMeter script before running loadBefore you trust the AI-made scriptRun 1 user,1 iterationOpen ViewResults TreeCheck DebugSampler valuesNo "NOT_FOUND"defaults in outputThen addloadAI can guess a wrong boundary or miss a hidden token. One clean single-user run tells you.
Five minutes of checking saves hours of confusing load test results.

Add a Debug Sampler and a View Results Tree, run one user once, and check every extracted variable. If you see NOT_FOUND anywhere, that extractor needs fixing. Paste the failing response back to the AI and ask it to correct the expression. This loop usually takes two or three rounds.

Where AI saves the most time

TaskWithout AIWith AI
Finding dynamic values in 60+ requests1 to 2 hoursAbout 10 minutes
Writing extractor expressions30 minutes, trial and errorAlmost instant, then verify
Naming transactions and adding assertionsTedious manual workDone in one prompt
Understanding why the script fails under loadStill needs youStill needs you

Frequently asked questions

Can Claude or ChatGPT read a HAR file directly?
Yes. Claude and ChatGPT both accept file uploads, so you can attach the HAR file. For very large files, upload a filtered recording or split it by business step.

Is it safe to share a HAR file with an AI tool?
Only after you remove passwords, cookies and authorization headers, and only with test data. Follow your company's AI usage policy.

Can the AI convert a LoadRunner script to JMeter?
Yes, and it works quite well for web_url and web_submit_data calls. I will cover that in a separate post in this series.

Does this replace JMeter's own recorder?
No. The HTTP(S) Test Script Recorder still works fine. The AI approach helps most with the correlation step, which the recorder does not do for you.

Wrapping up

Use AI as a fast junior teammate. Let it read the recording, find the tokens and write the first version of the script. Then do what an experienced performance engineer does: run one user, check every value, and only then add load.

Tomorrow in the AI in Performance Testing series: building a custom JMeter plugin with Claude, from an empty folder to a working sampler.

Page views