Skip to main content

Explain Regex API

Use the Explain Regex API to request a text explanation of a pattern.

Free
Unavailable
Pro
Requires account
Self-hosted
Included
Compare plans

On regex101.com, this endpoint requires an authenticated account. See API authentication.

On self-hosted deployments, configure access controls for this endpoint because it does not require account authentication.

Endpoint​

Send POST https://regex101.com/api/explain with Content-Type: application/json. Use the deployment's base URL for a self-hosted instance.

FieldRequiredMeaning
patternYesPattern text, up to 25,000 characters. Do not include enclosing delimiters.
parserOptionsYesObject containing flavor, flags, and delimiter.
verboseNoInclude supplemental details in text output; defaults to false.
indentSizeNoSpaces per text tree level, from 2 through 8; defaults to 4.

The request body limit is 256 KiB. The live API schema defines valid flags and delimiters for each flavor.

Text response​

Use this request body for a case-insensitive PCRE2 pattern:

{
"pattern": "[a-z]+",
"parserOptions": { "flavor": "pcre2", "flags": "i", "delimiter": "/" }
}

Save the body as explain-request.json. If your client has securely supplied REGEX101_TOKEN, send the request:

: "${REGEX101_TOKEN:?Set REGEX101_TOKEN through your credential configuration}"
curl --fail-with-body \
--header "Authorization: Bearer $REGEX101_TOKEN" \
--header "Content-Type: application/json" \
--data-binary @explain-request.json \
https://regex101.com/api/explain

The JSON response contains an explanation string. It describes the pattern and its flags.

Set verbose to true for supplemental details. Use indentSize to choose two through eight spaces per nesting level.

Invalid patterns​

An invalid regex can return HTTP 200 with an explanation.

For example, submit [ with the same parser options. The explanation describes the unclosed character class.

Request validation is different from pattern validation:

ResultWhat to verify
400Required fields, supported flavor, valid flags, and delimiter.
401A missing or expired credential where authentication is required.
403Account permissions or endpoint access controls.
413Request body size.
200 with a parser error explanationThe regex syntax in the selected flavor.

The response error envelope is described in API errors.

Use a local API request client to inspect explanations, parser feedback, and a corrected request.