Free tool - runs in your browser
Time regex tester
Test 24-hour HH:MM and HH:MM:SS, 12-hour h:mm AM/PM, optional leading zeros and ISO 8601 time with fractional seconds and offsets. Pick a preset, edit the regex and paste times one per line. Copy JavaScript, Python or an HTML pattern when you are ready.
Two-digit hours 00-23 and minutes 00-59. No seconds or time zone.
4 of 10 match
- Match
00:00 - Match
07:05 - Match
12:30 - Match
23:59 - No match
24:00 - No match
25:61 - No match
7:5 - No match
7:05 - No match
12:30:00 - No match
12:30 PM
HTML pattern uses the v flag and applies to text inputs, not type=time. Validate again on the server; Python snippets use ASCII matching to keep digit ranges consistent with JavaScript.
24-hour, 12-hour and ISO 8601 time patterns
Hours are limited to 00-23 and minutes and seconds to 00-59 in the 24-hour presets. The 12-hour preset uses 1-12 and requires AM/PM. Default pattern: ^([01]\d|2[0-3]):[0-5]\d$. Every preset below is checked against its match and no-match samples.
| Preset | Regex | Match / no match examples | Notes |
|---|---|---|---|
| 24-hour HH:MM | ^([01]\d|2[0-3]):[0-5]\d$ | Match: 00:00, 07:05, 12:30, 23:59No match: 24:00, 25:61, 7:5, 7:05, 12:30:00, 12:30 PM; empty string | Two-digit hours 00-23 and minutes 00-59. No seconds or time zone. |
| 24-hour with optional seconds | ^([01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?$ | Match: 00:00, 07:05, 12:30:00, 23:59:59No match: 24:00, 25:61, 7:5, 12:30:60, 12:30:5, 12:30:00.123; empty string | HH:MM or HH:MM:SS. Seconds, when present, need two digits from 00-59. |
| 24-hour with optional leading zero | ^([01]?\d|2[0-3]):[0-5]\d$ | Match: 0:00, 7:05, 07:05, 19:30, 23:59No match: 24:00, 25:61, 7:5, 007:05, 12:30:00; empty string | One or two hour digits; minutes still require two digits. Leading zero is optional. |
| 12-hour h:mm AM/PM | ^(0?[1-9]|1[0-2]):[0-5]\d\s?([AaPp][Mm])$ | Match: 7:05 AM, 07:05 pm, 12:00AM, 1:30 Pm, 12:59 PMNo match: 00:00 AM, 13:00 PM, 24:00, 25:61, 7:5 AM, 7:05, 7:05 AM; empty string | Hours 1-12 with optional leading zero, required AM/PM in either case, and zero or one whitespace character before it. |
| ISO 8601 time (extended format) | ^([01]\d|2[0-3]):[0-5]\d:[0-5]\d(\.\d+)?(Z|[+-]([01]\d|2[0-3]):[0-5]\d)?$ | Match: 00:00:00, 23:59:59.123456, 07:05:09Z, 12:30:00.5+05:30, 18:00:00-07:00No match: 24:00:00, 25:61:00, 7:5, 12:30, 12:30:60Z, 12:30:00.Z, 12:30:00+24:00, 12:30:00+05:60; empty string | Extended HH:MM:SS with optional fractional seconds and optional Z or +/-hh:mm offset. This subset excludes 24:00, leap seconds and basic format. |
| HTML input type=time value | ^([01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d{1,3})?)?$ | Match: 00:00, 07:05, 23:59:59, 12:30:00.1, 12:30:00.123No match: 24:00, 25:61, 7:5, 7:05, 12:30.123, 12:30:00.1234, 12:30Z, 1:30 PM; empty string | HH:MM or HH:MM:SS with optional 1-3 fractional digits after seconds. No AM/PM or time zone. Native min, max and step constraints are separate. |
Regex vs HTML input type=time
<label for="time-text">Time (HH:MM)</label>
<input id="time-text" name="time" type="text" pattern="([01]\d|2[0-3]):[0-5]\d" title="24-hour time, for example 07:05" required>
<label for="time-native">Local time</label>
<input id="time-native" name="local_time" type="time" step="0.001" required>A text input can enforce a custom format with the pattern attribute. HTML anchors the entire value and uses the v flag. Add required to reject an empty value. A native input type=time ignores pattern: it validates a local clock value using min, max and step. Its default step is 60 seconds; step=1 allows seconds and step=0.001 allows milliseconds.
Time zones and server validation
The ISO preset covers extended time-only strings such as 12:30:00.5Z and 12:30:00+05:30. It requires seconds and accepts optional fractions and an optional offset. It excludes dates, named zones, leap seconds and 24:00. An offset gives a UTC difference, not daylight saving rules. Use a date and a time zone with a date-time parser when you need an instant, and validate all submitted values on the server. For the date portion, try the date regex tester.
Time regex FAQ
Why does 24:00 fail the time regex?
These presets restrict hours to 00-23 and minutes and seconds to 00-59. Midnight is 00:00. Some ISO 8601 contexts allow 24:00 as the end of a day, but this tester deliberately uses a narrower range compatible with HTML time values. It also rejects 25:61 and leap seconds.
How do I match 12-hour time with AM/PM?
Choose the 12-hour preset. It accepts 7:05 AM, 07:05 pm and 12:00AM, with an optional leading zero and zero or one whitespace character before AM/PM. Hours must be 1-12, so 00:00 AM and 13:00 PM fail.
Should I use regex or input type=time?
Use input type=time for a native local-time picker. Its value uses 24-hour HH:MM or HH:MM:SS with optional fractional seconds, regardless of the displayed locale. The pattern attribute does not apply to type=time; use min, max and step instead. Use a text input with pattern when you need AM/PM or a custom text format. Validate again on the server.
Does the ISO time regex validate time zones?
The ISO preset accepts an optional Z for UTC or a numeric offset such as +05:30 or -07:00 after required seconds. It checks offset syntax and digit ranges, not named zones such as America/Denver, daylight saving rules or whether an offset is used in a real region. A time without an offset is a local clock reading, not a unique instant.
Can fractional seconds be used in an HTML time value?
Yes. The HTML preset accepts one to three decimal digits after seconds, such as 12:30:00.123. Use step=0.001 for millisecond precision in a native input; the default step is 60 seconds. The ISO preset allows any positive number of fractional digits.
Regex patterns for form fields
Alphanumeric regex tester
Test letters and numbers, spaces, handles and Unicode patterns.
Email regex tester
Test email patterns against edge cases and your own list.
Phone number regex tester
Check numbers against E.164, US/Canada and digits-only patterns.
Password regex generator
Pick strength rules and copy the regex or HTML pattern.
ZIP code regex
US ZIP, ZIP+4, Canadian and UK postal code patterns.
Number regex tester
Test digits, decimals, money and thousands separators.
Date regex tester
Date formats, strict ranges and leap-year aware ISO patterns.
Name regex tester
Validate names with accents, hyphens and apostrophes.
Username regex tester
Test username length, separators and reserved names.
IP address regex tester
Validate IPv4, IPv6 and CIDR input with strict octets.
URL regex tester
Check website fields with regex, type=url or new URL().
HTML pattern attribute
How browsers anchor and check a pattern on an input.
HTML required attribute
Stop a form from sending while a field is empty.
Validate a form with JavaScript
Use checkValidity, custom messages and your own rules.
Credit card regex tester
Match card brands by prefix and length, then run a Luhn check.
Hex color regex tester
Match hex, rgb() and hsl() colors with range checks and swatches.
UUID regex tester
Match UUID v4, v7 and GUIDs with version and variant checks.
Use your validation patterns as you assemble a form with our HTML contact form code or HTML form generator.
More free form tools
Form backend cost calculator
Enter monthly submissions and compare the cheapest listed plan across eight form backends.
Email deliverability checker
Enter a domain to check its SPF, DMARC and MX records and get a plain-English fix for each.
SPF record checker
Look up a domain's SPF record, see each mechanism explained and count DNS lookups against the 10-lookup limit.
DMARC record generator
Pick a policy and report address and copy a ready _dmarc TXT record.
DMARC checker
Look up a domain's DMARC record and see the policy and every tag explained.
DKIM record checker
Enter a domain and selector to check its DKIM key, with presets for common senders.
SPF record generator
Tick your email providers and copy one SPF TXT record with a lookup count.
Contact form spam checker
Paste form HTML to audit its honeypot, endpoint, CAPTCHA markers and spam resistance.
Honeypot field generator
Generate a hidden anti-spam input with your chosen name and hiding technique.
Form action URL tester
Check a form action URL for reachability, CORS headers, POST acceptance and backend.
Email obfuscator
Encode your email so spam scrapers can't read it but people can still click it.
Mailto link generator
Build a mailto: URL with recipients, CC, BCC, subject and a pre-filled body.
HMAC-SHA256 generator
Generate and verify webhook signatures for common providers in your browser.
URL encoder and decoder
Encode text, build an x-www-form-urlencoded body or parse a query string.
UTM builder
Build campaign URLs with UTM parameters, tag a CSV in bulk and check tagged links.
HTML to JSX converter
Paste HTML and get JSX or a working React/Next.js form component.
Image to Base64 converter
Convert images to Base64 data URLs in your browser and copy HTML and CSS snippets.
Base64 to image converter
Paste a Base64 data URI to preview and download the decoded image.
Base64 decode & encode
Decode Base64 to readable UTF-8 text or encode text to Base64, locally in your browser.
URL to Base64 converter
Fetch a direct image URL in your browser and get its Base64 data URL.
AI form generator
Describe your form in plain English and copy working HTML.