Code Beautifier
must match format

Fix JSON Schema "must match format"

Ajv's error when a string fails a format keyword such as email, uri, date-time, or uuid. What each format accepts, why validation may be off, and the fix.

Input that triggers it

{
  "schema": {
    "type": "object",
    "properties": {
      "email": { "type": "string", "format": "email" },
      "createdAt": { "type": "string", "format": "date-time" }
    }
  },
  "data": { "email": "ada.example.com", "createdAt": "2026-09-13" }
}
Draft saved locally.

Local workspace

Named projects in IndexedDB · Local only — never synced to our servers. Worksp

Open manager

Batch workspace

Format multiple files locally in one run.

json
Formatted Outputtext

What the error means

The type keyword checks that a value is a string; the format keyword checks what the string looks like. JSON Schema defines a set of named formats — email, uri, date, date-time, time, uuid, ipv4, ipv6, hostname, regex, and others — each with a precise syntax borrowed from an RFC. must match format "email" is Ajv's report that a string is well-typed but does not satisfy the named format, with instancePath pointing at the property.

The example fails twice: ada.example.com has no @, so it is not an email address, and 2026-09-13 is a date, not a date-time, which requires a time and a timezone offset (2026-09-13T10:00:00Z).

Why it happens

  • The value is genuinely malformed — a missing @, a URL without a scheme, a UUID with the wrong group lengths.
  • The wrong format was chosen. date versus date-time is the classic pair; time and duration are others. Each is exact and none accepts the others' syntax.
  • The data uses a looser convention than the RFC. Dates like 13/09/2026, emails with display names (Ada <ada@example.com>), or URIs with spaces are all rejected.
  • A format the validator does not know. Custom names such as phone or slug are not standard; whether they fail or are ignored depends on the validator's strictness setting.
  • Format validation was previously off. In draft 2019-09 and later, format is an annotation by default and only asserts when the validator is configured to; a validator upgrade that turns assertion on surfaces long-standing bad data.

How to fix it

  1. Paste the schema and data into the validator above. Each failing property is listed with its path and the format it missed.
  2. If the value is wrong, correct it at the source: add the @, produce a full date-time from the timestamp rather than a bare date.
  3. If the format is wrong, change the schema keyword to the one that matches the data — date for 2026-09-13.
  4. If the constraint is not wanted, remove format; keep type: "string" so the value is still checked for being text. For a custom shape, use pattern with a regular expression instead, and test it with Regex Tester.

Data that satisfies the example schema:

{ "email": "ada@example.com", "createdAt": "2026-09-13T10:00:00Z" }

If it still fails

  • Ajv needs the ajv-formats plugin to know the standard formats; without it, format is either ignored or an error in strict mode, depending on configuration. The validator above includes it.
  • email validation in "fast" mode accepts some addresses that stricter checks reject, and vice versa; do not rely on the keyword as the sole gate for anything security-sensitive.
  • JSON to JSON Schema infers format for values that already look like emails, URIs, and timestamps in the sample, which is a good way to see which formats your data actually matches.

Related errors