ForHosting KIT · Developer Utilities

Explain a regex

Every developer has stared at a regular expression left behind by someone who no longer works there, unsure whether it's safe to touch. This endpoint takes that expression and returns a plain-language breakdown of what each group, anchor and quantifier is actually doing.

● StablePer request + per item$0.003
Use it from WebAPIEmailApp soonTelegram soon

Run this on our servers with your account. Free tools run in your browser; this one bills your KIT balance per the price above.

The comment that was never written

A regular expression is one of the few pieces of code that can be simultaneously correct, load-bearing, and completely opaque to the next person who reads it. It rarely comes with a comment explaining why the pattern excludes a certain character or why there's a lookahead buried in the middle, because the person who wrote it understood it perfectly at the time and never expected to need the explanation later. dev.regex_explain exists for the moment six months on, when someone else — or the same person — needs to know exactly what that pattern does before changing it.

From symbols to sentences

POST /dev/regex-explain with the expression you want broken down, and the call returns a task_id while the pattern is parsed and translated into plain language. The result arrives by signed webhook or a signed link valid for 24 hours, and walks through the expression piece by piece — what each group captures, what each anchor requires, what each quantifier allows — rather than handing back a single vague summary of the whole thing.

Why the same twelve characters can mean different things

A big part of what makes regex hard to read cold is that its symbols are heavily overloaded and context-dependent: a question mark means zero-or-one after a token but switches to non-greedy after a quantifier, and a set of parentheses might be a capturing group, a non-capturing group, or a lookahead depending on two characters right after the opening parenthesis. Different engines — PCRE, POSIX, the flavors built into Python, JavaScript and Java — also support slightly different extensions, so a pattern that looks unfamiliar might simply be using syntax from an engine you don't work with often. Explaining a pattern accurately means identifying which flavor it's written in as much as parsing the symbols themselves.

Where it earns its keep in day-to-day work

Code review is the most obvious use — a reviewer can paste an unfamiliar pattern from a pull request and get a clear description of its behavior in the time it takes to read a sentence, rather than mentally tracing through nested groups. It also pulls its weight in onboarding, where a new engineer inherits a codebase full of validation patterns nobody wrote documentation for, and in security audits, where understanding exactly what an input-sanitizing regex does and doesn't block matters more than being able to write one from scratch. Billed per request plus per pattern item with no charge on a failed explanation, it's cheap enough to run against every regex a linter flags as suspicious rather than only the ones someone finally gets around to investigating.

Code review of an unfamiliar pattern

A reviewer pastes a regex from a pull request to get a clear description of its behavior before approving a change to validation logic.

Onboarding onto a legacy codebase

A new engineer explains every undocumented regex in an inherited validation module to understand what input rules are actually being enforced.

Security audit of input sanitization

A security review explains a sanitization pattern to confirm exactly which characters and sequences it blocks before signing off on a form.

Documentation generation

A documentation tool explains each regex used in a public API's parameter validation so the docs describe accepted formats in plain language.

How do I get an explanation of a regex with the API?

POST the expression to /dev/regex-explain, keep the returned task_id, and collect the plain-language breakdown by webhook or a signed link valid for 24 hours.

Is the regex explainer API free?

No, there is no free tier or trial; it costs $0.003 per request plus $0.0135 per item, and a failed explanation is never charged.

Does it support every regex flavor?

It handles the common flavors including PCRE and the variants built into major languages; mention the source language if the pattern uses less common extensions.

Does it explain the whole expression or just parts of it?

It breaks the expression into its components — groups, anchors, quantifiers, character classes — and explains each one rather than giving a single vague summary.

Can I explain multiple patterns in one request?

Yes, submit multiple items in one task and each is priced individually at the per-item rate, useful when auditing a whole file of validation patterns.

Will it tell me if a regex is inefficient or risky?

The explanation describes what the pattern matches; if a construct is prone to catastrophic backtracking or unusually broad matching, that's noted as part of the plain-language description.

Is this endpoint live?

Yes, /dev/regex-explain is live and accepting requests now.

Is the pattern I submit stored afterward?

No, submitted patterns and their explanations are deleted after the retention window and are never used for training.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/dev/regex-explain

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, and soon from our app, email and Telegram.

curl -X POST https://api.kit.forhosting.com/dev/regex-explain \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"items":["valor-1","valor-2"]}'
{
  "items": [
    "valor-1",
    "valor-2"
  ]
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "dev.regex_explain",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.003
Per item$0.0135

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.
422task_failedThe task failed after 3 retries. You are never charged for it.

Read the full KIT documentation →