# unjs/magic-regexp

A compiled-away, type-safe, readable RegExp alternative

Repository: https://github.com/unjs/magic-regexp
Canonical: https://ross.abutalabs.com/products/magic-regexp
Homepage: https://regexp.dev
Language: TypeScript
License: MIT
License Family: permissive
Topics: regexp, typescript, regex, regular-expression, hacktoberfest
Last push: 2026-08-24T07:33:54+00:00

## Health v2 (maintenance only)
Score: 82/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 99, release rhythm 49, longevity 100
- inputs: {"age_days": 1509, "days_push": 9, "days_rel": 181, "gap_med": 165.0, "n_releases_24m": 3}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 4335, forks 72 (observed 2026-08-28T04:08:46.043885+00:00)

## What it is
magic-regexp is a TypeScript library providing a readable, natural-language builder for regular expressions with automatically typed capture groups. It ships with build-time transforms (for Nuxt, Vite, webpack, unbuild) that compile expressions to plain RegExp for zero runtime overhead.

## Use cases
- write readable regex without cryptic syntax
- get type-safe capture groups from regular expressions
- compile regex builders away at build time to plain RegExp
- build regular expressions with a natural language fluent API
- validate and extract strings with typed regex matches

## When to choose
- you want maintainable, self-documenting regex in a TypeScript project
- you need typed capture groups instead of untyped match results
- you use Nuxt, Vite, or webpack and want zero-runtime compiled regex

## When to avoid
- you need advanced regex features not covered by the builder API
- you are not using TypeScript and cannot benefit from the type safety
- you need maximum performance from hand-tuned raw regex

## Facets
- artifact type: library
- maturity: active
- function: parser, developer-tools, type-system
- domain: developer-tools, programming-languages, web-development
- platform: cross-platform
- tags: regex, regexp, type-safe, build-time-transform, nuxt, vite-plugin, nodejs, typescript

## Member repositories
- unjs/magic-regexp (main) score 82

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:08:46.043885+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T18:21:38.725307+00:00, confidence not recorded.
  - readme: https://github.com/unjs/magic-regexp (fetched 2026-08-28T04:08:46.043885+00:00, sha 8ca2945e0953)
  - homepage: https://regexp.dev (fetched 2026-08-29T09:10:39.806177+00:00, sha 40ee956c88dc)
  - site_page: https://regexp.dev/guide (fetched 2026-08-29T09:10:39.913690+00:00, sha b520b7b2812a)
  - registry_npm: https://registry.npmjs.org/magic-regexp (fetched 2026-08-29T09:10:40.349416+00:00, sha 5db0e5627cba)
- Data as of 2026-08-30T08:39:29.467469+00:00.
