DevTools Logo

WireMock Stub Builder

WireMock Stub Builder

Author WireMock mapping JSON with exact request matchers, responses, delays and faults — validated locally and ready to copy.

Runs in your browser
Try an example

Stub 1 of 1

0 error(s) · 0 warning(s)
Request

Headers

Query parameters

Body patterns

Response
Metadata
JSON path checker

Mapping is valid. Ready to copy or download.

Mapping JSON

1 stub(s) · bare mapping
{
  "request": {
    "method": "GET",
    "urlPath": "/api/resource"
  },
  "response": {
    "status": 200,
    "headers": {
      "Content-Type": "application/json"
    },
    "jsonBody": {
      "ok": true
    }
  },
  "name": "stub-1"
}

Admin API: curl -X POST "http://localhost:8080/__admin/mappings" -H "Content-Type: application/json" -d @wiremock-mappings.json

Details

Fill in request and response forms and get valid WireMock 3.x mapping JSON. Choose exact URL, path or regex matchers; add header, query and body matchers including equalToJson compare modes and matchesJsonPath; configure status, JSON or text bodies, delays, fault simulation and stateful scenarios. A single stub is emitted as a bare mapping object and multiple stubs as a mappings wrapper, with an admin API curl snippet. Local validation checks JSON bodies, regex patterns and JSONPath expressions before you copy or download; nothing leaves the browser tab.

More examples

GET by regex

urlPathPattern: /api/users/[0-9]+ → 200 JSON body

A regex URL matcher with a JSON response body, emitted as a bare mapping ready for mappings/.

Header gate

headers: X-Api-Key equalTo secret

Header matchers are emitted under request.headers with equalTo, not the Java DSL's withHeader method.

Stateful flow

scenarioName: checkout; requiredScenarioState: Started; newScenarioState: Paid

WireMock scenario keys are top-level scalars, not a nested scenario object.

Examples

Path regex

Input
urlPathPattern: /api/users/[0-9]+
Output
"urlPathPattern": "/api/users/[0-9]+"

The regex goes directly under request; it is not wrapped in a matcher object.

JSON compare mode

Input
equalToJson {"id":1} with IGNORE_ARRAY_ORDER
Output
"jsonCompareMode": "IGNORE_ARRAY_ORDER"

Compare modes tune how strictly the expected JSON is matched against the request body.

JSON path preview

Input
$.items[*].id over {items:[{id:1},{id:2}]}
Output
Matched 2: 1, 2

The local checker supports the common dot/bracket subset; deep scans are only a warning.

About this tool

WireMock Stub Builder turns a form into WireMock 3.x mapping JSON. Choose an exact URL, URL path, path regex or full-URL regex, add header and query matchers, and describe request bodies with equalTo, contains, matches, equalToJson or matchesJsonPath. The emitted keys match the mapping-file schema exactly, including request.headers and top-level scenarioName, requiredScenarioState and newScenarioState.

A single stub is emitted as a bare mapping object — the shape both mappings/ files and POST /__admin/mappings expect. Multiple stubs are wrapped in a { "mappings": […] } file. Responses support status codes, JSON or text bodies, response headers, fixed and distributed delays, faults such as CONNECTION_RESET_BY_PEER, and the response-template transformer.

Local validation runs as you edit: JSON bodies are parsed with an offset, regex patterns are compiled (with an explicit note for Java-only syntax), and matchesJsonPath expressions can be tested against a sample payload using the supported dot/bracket subset. Deep-scan (..) expressions get a warning but still emit valid WireMock matchers.

Four presets — REST CRUD, webhook receiver, chaos faults and a stateful scenario — are one click away. Existing mapping files and admin dumps can be imported back into the form; unknown keys are preserved on export rather than silently dropped. Everything happens in the browser tab, and the curl snippet is displayed, never executed.

What this tool does not do

  • The emitter targets WireMock 3.x mapping JSON; extensions and transformers beyond response-template are only preserved on import.
  • The local JSONPath checker covers a common subset, not full JsonPath; deep scans are emitted but not previewed.
  • Regex validation uses JavaScript's engine, so Java-only constructs are warned about rather than compile-checked.
  • The curl snippet is informational; the tool never calls a running WireMock server.
  • Workspace stubs are not persisted between visits; export your mapping file to keep them.

How to use this tool

  1. Describe the request

    Pick a URL matcher type and pattern, choose the HTTP method, then add header, query and body matcher rows as needed.

  2. Configure the response

    Set status, body and headers. Add a fixed delay or distribution, a fault for resilience tests, or enable the response-template transformer.

  3. Add metadata

    Name the stub, set priority (lower wins), and configure scenario states for stateful flows.

  4. Validate and check paths

    Read the validation strip for JSON or regex errors. Paste a sample payload in the JSON path checker and click Test match to preview extracted values.

  5. Export or import

    Copy or download the mapping JSON, or import an existing mappings file (or admin dump) to edit it in the form.

Use cases

CI test doubles

Author deterministic third-party stubs with exact header and body matchers for integration tests.

Contract fixtures

Keep request/response examples in WireMock's native format and review them as readable form fields.

Resilience testing

Add delays and faults to exercise client timeouts and retry logic.

Stateful flows

Model multi-step flows with scenario names and state transitions across several stubs.

Matcher keys emitted

ChoiceWireMock JSON
equalTo / contains / matches{ "equalTo": "value" } and friends
equalToJson{ "equalToJson": {…}, "jsonCompareMode": "IGNORE_ARRAY_ORDER" }
matchesJsonPath{ "matchesJsonPath": "$.items[*].id" } or an expression + inner matcher object
headers / queryParametersrequest.headers = { "Name": [{ matcher }] }
delays and faultsresponse.fixedDelayMilliseconds, response.delayDistribution, response.fault
scenarioTop-level scenarioName, requiredScenarioState and newScenarioState

Single stubs export as a bare mapping; two or more export inside a mappings wrapper file.

Common mistakes

Mistake:Wrapping a single mapping in a mappings array.

Fix:Single stubs export as a bare object; only multi-stub files use the wrapper.

Mistake:Using withHeader or a nested scenario object.

Fix:Mapping JSON uses request.headers and top-level scenarioName/requiredScenarioState/newScenarioState.

Mistake:Using randomDelay instead of delayDistribution.

Fix:The mapping schema uses response.delayDistribution with a type discriminator.

Mistake:Believing a Java regex that fails in JavaScript is invalid.

Fix:The validator flags Java-only syntax as a warning; WireMock's Java engine still accepts it.

Mistake:Expecting deep JSONPath scans to be checked locally.

Fix:The checker covers $, .key, [n], [*] and bracket keys; .. is warned about but emitted unchanged.

Frequently asked questions

What is the difference between url and urlPathPattern?

url matches the complete URL including the query string, urlPath matches just the path exactly, urlPathPattern applies a regex to the path only, and urlPattern applies a regex to the full URL. The builder emits the key you choose directly under request; a single stub exports as a bare mapping object.

How does matchesJsonPath work?

matchesJsonPath extracts a value from the request body using a JsonPath expression and optionally matches it with an inner matcher such as equalTo. The local checker supports $, .key, [n], [*] and bracket keys so you can preview extracted values against a sample payload. Deep scans like $..price are warned about but emitted unchanged — WireMock's full JsonPath engine handles them at runtime.

How do I set stub priority?

Enter a number in Metadata. Lower numbers win: WireMock evaluates stubs by priority, then by insertion order, so the first matching stub with the lowest priority serves the request. The builder warns when two stubs share both a pattern and a priority.

How do stateful scenarios work?

Give several stubs the same scenarioName, then set requiredScenarioState on each and newScenarioState where the state should advance. WireMock starts from the state Started. The emitted keys are top-level scalars (scenarioName, requiredScenarioState, newScenarioState), and the tool reports an error if you configure states without a scenario name.

How do I deploy the JSON to WireMock?

Download the mapping file and drop a single bare mapping into your mappings/ directory, or put a multi-stub mappings wrapper there. For a running server, the displayed curl snippet POSTs the file to /__admin/mappings. The snippet is shown as text and is never executed by the tool.

Does my stub data leave the browser?

No. Building, validation, JSONPath preview and import all run locally. Stub bodies often contain internal API shapes, so nothing is uploaded and nothing is persisted on a server. Existing mappings you import stay in the tab until you export them.

References & standards