Explain Regex API
Use the Explain Regex API to request a text explanation of a pattern.
- Free
- Unavailable
- Pro
- Requires account
- Self-hosted
- Included
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.
| Field | Required | Meaning |
|---|---|---|
pattern | Yes | Pattern text, up to 25,000 characters. Do not include enclosing delimiters. |
parserOptions | Yes | Object containing flavor, flags, and delimiter. |
verbose | No | Include supplemental details in text output; defaults to false. |
indentSize | No | Spaces 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:
| Result | What to verify |
|---|---|
400 | Required fields, supported flavor, valid flags, and delimiter. |
401 | A missing or expired credential where authentication is required. |
403 | Account permissions or endpoint access controls. |
413 | Request body size. |
200 with a parser error explanation | The regex syntax in the selected flavor. |
The response error envelope is described in API errors.