Home › Developer Tools › Regex Generator

Regex Generator

Build a regular expression without memorising the syntax: stack blocks such as digits, letters, exact text, character sets and either/or choices, set how often each repeats, or start from a ready-made preset. The regex, a plain-English description, a live test and code snippets update instantly.

Last updated:

Start from a preset
Your regex

Pattern blocks

    Add a block

    In plain English

      
            

      Advertisement
      Advertisement

      How to use the Regex Generator

      1. Pick a preset such as Email or Date, or start from scratch with Clear all.
      2. Add blocks from the palette: for example Digits, then Exact text "-", then Digits again.
      3. Set how many times each block repeats (exactly once, optional, one or more, exactly N, N to M) and tick capture to save a part as a group.
      4. Choose options: keep Match whole input on for validation, or turn it off to find matches inside longer text; toggle flags like ignore case.
      5. Test and copy: type sample lines to see which match, then copy the regex or the code for your language.

      Common regex patterns

      UseRegexMatches
      Email (practical)^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$[email protected]
      Date YYYY-MM-DD^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$2026-10-20
      Time 24h^(?:[01]\d|2[0-3]):[0-5]\d$23:59
      US phone^\(?\d{3}\)?[-. ]?\d{3}[-. ]?\d{4}$(555) 123-4567
      Phone E.164^\+[1-9]\d{1,14}$+14155552671
      US ZIP^\d{5}(?:-\d{4})?$94105-1234
      Hex color^#(?:[0-9a-f]{6}|[0-9a-f]{3})$ (with i)#2f6b4f, #fff
      URL slug^[a-z0-9]+(?:-[a-z0-9]+)*$my-first-post
      Integer^-?\d+$-42
      Decimal^[-+]?\d+(?:\.\d+)?$3.14

      Validation vs. extraction

      A regex used to validate a single value (a form field, a file name, an ID) should be anchored with ^ and $, otherwise "abc123xyz" would pass a digits-only check because it contains digits. A regex used to extract values from a longer text must not be anchored to the whole input, and usually needs the g flag so that every occurrence is found. Word boundaries (\b) help to avoid matching inside longer words or numbers.

      Regular expressions check the shape of text, not its meaning. A date regex can reject month 13, but checking that February 30 does not exist, that an email inbox is real or that a credit card number passes the Luhn check needs code.

      Frequently asked questions

      How do I create a regex without knowing the syntax?

      Describe the text as a sequence of parts. For a product code like AB-1234 you would add Uppercase (exactly 2), Exact text "-" and Digits (exactly 4). The generator turns that into ^[A-Z]{2}-\d{4}$, escapes special characters for you and shows which of your test lines match.

      What does "Match whole input" do?

      It wraps the pattern in ^ and $ so the entire value must match, which is what you want for validating form fields. Turn it off to search for the pattern anywhere inside a longer text, for example to extract all prices or hashtags from a paragraph.

      Is the email regex fully RFC 5322 compliant?

      No regex that people can maintain is. The preset accepts the addresses used in practice (letters, digits, dots, plus, percent, hyphen and underscore before the @, a domain and a TLD of at least two letters) and rejects obvious mistakes. To be sure an address exists, send a confirmation email.

      What is the difference between capture and non-capturing groups?

      A capturing group saves the matched text so you can read it later (match[1] or match.groups.name in JavaScript). The generator automatically uses non-capturing groups (?:…) when it only needs parentheses to apply a quantifier, so your group numbers stay predictable.

      Will the regex work in Python, PHP or Java?

      The code tab converts the pattern for each language: Python gets (?P<name>…) groups and re flags, PHP gets delimiters and escaped quotes, Java and C# get properly escaped string literals and Ruby uses \A and \z for whole-input matching. Go's RE2 engine does not support lookarounds or backreferences, and the tool warns you when a pattern uses them.

      What does lazy mean?

      By default quantifiers are greedy and match as much as possible. A lazy quantifier matches as little as possible, which matters when the same character can appear later, for example matching the shortest text between two quotes.

      Are all the tools on FreeToolCabin tested for quality and accuracy?

      Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

      Related tools

      Regex ExplainerPaste a regular expression and get a plain-English breakdown, railroad diagram and flag notes.Regex TesterTest and debug regular expressions live.Regex Cheat Sheet75+ ready-to-use regex patterns for emails, URLs, IPs and dates, each with a live test box.jq PlaygroundRun jq filters on JSON in your browser with live output, flags and an example library.QR Code GeneratorMake QR codes for links, Wi-Fi, email and more.Barcode GeneratorCreate Code 128, EAN-13, UPC-A, EAN-8, Code 39 and ITF-14 barcodes as PNG or SVG.UUID GeneratorGenerate UUID v4 and v7 / GUIDs in bulk and copy or download them.Schema Markup Generator (JSON-LD)Create JSON-LD structured data for FAQ, Product, Article and more.Htaccess & Nginx Redirect GeneratorBuild 301 redirects for .htaccess, Nginx and Netlify or Cloudflare _redirects.Fake Data GeneratorGenerate mock data as JSON, CSV or SQL.Random String GeneratorGenerate secure random strings and tokens in bulk with any length and character set.API Key GeneratorCreate secure API keys and secrets with prefixes, checksums and SHA-256 hashes for storage.MIME Type LookupFind the MIME type for any file extension, or the extensions for a MIME type, in 400+ entries.Cron Expression GeneratorBuild crontab schedules visually, read them in plain English and see the next run times.URL Slug GeneratorTurn titles into clean, SEO-friendly URL slugs: accents, stop words, separators and bulk lines.JSON Schema GeneratorTurn sample JSON into a draft 2020-12 JSON Schema with types, required fields and formats.Gitignore GeneratorBuild a .gitignore from 50+ templates for languages, frameworks, IDEs and OS, merged and deduped.License GeneratorCreate a LICENSE file for MIT, Apache, GPL, BSD, ISC, MPL or Unlicense with your name and year.ULID GeneratorGenerate sortable ULIDs and UUID v7 in bulk, monotonic option, and decode their timestamps.Htpasswd GeneratorCreate .htpasswd entries with bcrypt, APR1-MD5 or SHA-1 for Apache and Nginx basic auth.Placeholder Image GeneratorCreate placeholder images in any size, color and text as PNG, JPG, WebP, SVG or data URI.Ads.txt GeneratorCreate or validate ads.txt and app-ads.txt files: seller lines, cert IDs and variables.Docker Run to Compose ConverterConvert docker run commands to docker-compose.yml, or a compose file back to docker run.Dockerfile GeneratorGenerate a production Dockerfile and .dockerignore for Node, Python, Go or a static nginx site.HTML Boilerplate GeneratorTick the options you need and get a clean HTML5 starter template with meta, OG tags and CSS reset.JSON to Zod SchemaInfer a Zod (or Yup) schema from sample JSON with optional, nullable and z.infer types.Linux Commands Cheat SheetSearchable Linux and bash command reference with flags explained, examples and copy buttons.LLMs.txt GeneratorBuild an llms.txt file for AI crawlers: summary and link sections, import from your sitemap.Nano ID GeneratorGenerate secure Nano IDs with custom alphabet, length and count, plus a collision calculator.Nginx Config GeneratorBuild an nginx server block: static site, SPA, reverse proxy or PHP, with SSL, gzip and redirects.OpenAPI / Swagger ViewerView OpenAPI 2/3 JSON or YAML as interactive API docs with validation and an endpoint list.package.json GeneratorFill a form and get a valid, npm-ready package.json with scripts, dependencies and checks.PKCE Code Challenge GeneratorGenerate an OAuth 2.0 PKCE code_verifier and S256 code_challenge, build auth URLs, verify pairs.README GeneratorFill in a form and get a polished README.md with badges, install, usage and license, live preview.Commit Message GeneratorBuild Conventional Commit messages with type, scope, body, breaking change and issue refs.Database Schema DesignerDesign tables and relationships visually, then export SQL for MySQL, PostgreSQL or SQLite.Docker Compose GeneratorBuild a docker-compose.yml with a form: services, ports, volumes, env, healthchecks and presets.Dummy File GeneratorCreate test files of an exact size in KB, MB or GB with zeros, random bytes or text.FFmpeg Command GeneratorPick a task and options, get the exact ffmpeg command with every flag explained.Folder Tree GeneratorTurn a local folder or an indented list into an ASCII directory tree for your README.GitHub Actions Workflow GeneratorBuild a GitHub Actions CI workflow: triggers, matrix, caching, tests, Pages or Docker deploy.Kubernetes YAML GeneratorGenerate Deployment, Service, Ingress, ConfigMap, Secret and HPA manifests with safe defaults.Markdown TOC GeneratorGenerate a linked table of contents from Markdown headings with GitHub-style anchors.OpenAPI EditorEdit OpenAPI/Swagger YAML or JSON side by side with live API docs, validation and download.OpenAPI ValidatorValidate OpenAPI 3.0/3.1 and Swagger 2.0 specs: schema errors, broken $refs, line numbers.Pivot Table MakerBuild pivot tables from CSV or Excel by drag and drop: sum, count, average, charts, export.SQL Query BuilderBuild SELECT queries visually: joins, filters, GROUP BY, ORDER BY and LIMIT, as clean SQL.Truth Table GeneratorType a logic expression and get its full truth table, minterms and canonical DNF/CNF.TypeScript PlaygroundWrite TypeScript with live type checking, see the compiled JavaScript and run it in your browser.Article Schema GeneratorCreate Article, BlogPosting or NewsArticle JSON-LD with headline, authors, dates and images.Event Schema GeneratorCreate Event JSON-LD with dates, venue or online location, tickets, organizer and performers.Google Search Query BuilderBuild advanced Google searches with site:, filetype:, intitle:, exact phrases and date operators.HowTo Schema GeneratorCreate HowTo JSON-LD with steps, tools, supplies, total time and cost, then copy it.Htaccess GeneratorBuild an Apache .htaccess file: HTTPS, www, gzip, caching, error pages, IP blocks, hotlinks.HTML Email Template BuilderDrag and drop blocks to build a responsive, table-based HTML email with inline styles.Organization Schema GeneratorCreate Organization JSON-LD with logo, URL, contact points, address and social profiles.PIN GeneratorGenerate random 4, 6 or 8-digit PINs that avoid sequences, repeats, dates and common PINs.Product Schema GeneratorBuild Product JSON-LD with price, availability, brand, GTIN, ratings and reviews.Question Keyword GeneratorFind the questions people ask about a topic, grouped by who, what, why, how, can and more.Recipe Schema GeneratorCreate Recipe JSON-LD with ingredients, steps, prep and cook times, nutrition and ratings.Security Headers GeneratorPick HSTS, CSP, frame, referrer and permissions options and get Apache, Nginx, Netlify or Cloudflare config.SKU GeneratorBuild consistent SKUs from brand, category, size and color, then export every variant as CSV.Typography Scale GeneratorBuild a modular type scale from a base size and ratio, then copy CSS variables or a Tailwind config.WordPress Salt GeneratorGenerate fresh WordPress security keys and salts for wp-config.php, .env or Docker in one click.ANSI Color Code GeneratorStyle terminal text with 16, 256 or RGB colors and get escape codes for bash, Python, JS and C.Apache Virtual Host GeneratorCreate an Apache VirtualHost config with SSL, redirects, reverse proxy or PHP-FPM in seconds.Bash Prompt GeneratorDrag and drop a custom PS1 prompt for bash or zsh with colors, git branch and a live preview.Changelog GeneratorTurn Conventional Commit messages into a grouped Keep a Changelog Markdown file per version.
      See all 85 Code Generators & Builders →