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.
Run it online
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.
What you can do with it
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.
FAQ
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.
For developers — API access
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.
API endpoint
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.
Call it from your stack
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"]}'const res = await fetch("https://api.kit.forhosting.com/dev/regex-explain", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"items": [
"valor-1",
"valor-2"
]
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/dev/regex-explain",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"items": [
"valor-1",
"valor-2"
]
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/dev/regex-explain", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"items":["valor-1","valor-2"]}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"items":["valor-1","valor-2"]}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/dev/regex-explain", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"items": [
"valor-1",
"valor-2"
]
}Example response
{
"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.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
422 | task_failed | The task failed after 3 retries. You are never charged for it. |