RegEx Tester API

Test and debug regular expressions live. Match highlighting, capture group inspection, flag toggles, and pattern explanations — 100% client-side.

The RegEx Tester is also available as a free REST API. Send a POST request with a JSON body to https://dot.tools/api/tools/regex-tester — no authentication, no API key, CORS enabled. Successful calls return { "ok": true, "result": { … } }; failures return HTTP 400 or 422 with an error body.

Request body

FieldTypeRequiredDescription
patternstringrequiredThe JavaScript regular expression pattern (without slashes). Capped at 500 characters as a ReDoS guard.
textstringrequiredThe test text to match against. Capped at 100,000 characters as a ReDoS guard.
flagsobjectrequiredRegular expression flags.

Response

FieldTypeRequiredDescription
validbooleanrequiredWhether the pattern compiled successfully.
errorunknownrequiredParse error message when the pattern is invalid.
matchCountnumberrequiredTotal number of matches found.
truncatedbooleanrequiredWhether the matches list was capped at 1000 entries.
matchesobject[]requiredAll matches (capped at 1000).
explanationobject[]requiredToken-by-token explanation of the pattern.

Example request

curl -X POST https://dot.tools/api/tools/regex-tester \
  -H 'Content-Type: application/json' \
  -d '{
  "pattern": "(?<user>[\\w.+-]+)@(?<domain>[\\w-]+\\.[\\w.]+)",
  "text": "Contact us:\n  support@bitgate.com\n  sales@bitgate.com\n  kevin.schipper+tools@bitgate.com\n\nInvalid entries:\n  not-an-email\n  @missing-user.com\n  missing-at-sign.com",
  "flags": {
    "global": true,
    "ignoreCase": false,
    "multiline": true,
    "dotall": false,
    "unicode": false,
    "sticky": false
  }
}'

Sample response

{
  "ok": true,
  "result": {
    "valid": true,
    "error": null,
    "matchCount": 3,
    "truncated": false,
    "matches": [
      {
        "index": 1,
        "text": "support@bitgate.com",
        "range": [
          14,
          33
        ],
        "groups": [
          {
            "index": 1,
            "name": "user",
            "value": "support"
          },
          {
            "index": 2,
            "name": "domain",
            "value": "bitgate.com"
          }
        ]
      },
      {
        "index": 2,
        "text": "sales@bitgate.com",
        "range": [
          36,
          53
        ],
        "groups": [
          {
            "index": 1,
            "name": "user",
            "value": "sales"
          },
          {
            "index": 2,
            "name": "domain",
            "value": "bitgate.com"
          }
        ]
      },
      {
        "index": 3,
        "text": "kevin.schipper+tools@bitgate.com",
        "range": [
          56,
          88
        ],
        "groups": [
          {
            "index": 1,
            "name": "user",
            "value": "kevin.schipper+tools"
          },
          {
            "index": 2,
            "name": "domain",
            "value": "bitgate.com"
          }
        ]
      }
    ],
    "explanation": [
      {
        "token": "(?<user>",
        "description": "start of named capture group 1 \"user\""
      },
      {
        "token": "[\\w.+-]",
        "description": "any single character in this set"
      },
      {
        "token": "+",
        "description": "preceding token repeated one or more"
      },
      {
        "token": ")",
        "description": "end of group"
      },
      {
        "token": "@",
        "description": "literal \"@\""
      },
      {
        "token": "(?<domain>",
        "description": "start of named capture group 2 \"domain\""
      },
      {
        "token": "[\\w-]",
        "description": "any single character in this set"
      },
      {
        "token": "+",
        "description": "preceding token repeated one or more"
      },
      {
        "token": "\\.",
        "description": "literal \".\""
      },
      {
        "token": "[\\w.]",
        "description": "any single character in this set"
      },
      {
        "token": "+",
        "description": "preceding token repeated one or more"
      },
      {
        "token": ")",
        "description": "end of group"
      }
    ]
  }
}

Use the free RegEx Tester in your browser, read the RegEx Tester guide, or import the full OpenAPI specification.