# ajv-formats — card for AI agents

Format validation plugin for Ajv JSON schema validator (email, UUID, date, etc).

Category: Forms, validation and schemas · npm package `ajv-formats` · latest version 3.0.1 (checked 2026-11-01)
Install: `npm install ajv-formats`
License: MIT (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Numbers (AgentGid data)
- Gid Score: 59.4 (#1071 of all tools, 24 of 63 in its category)
- Used in 58 public projects set up for AI coding agents (0.9%)
- Downloads last week: 216,930,726 (as of 2026-11-24), +47.4% over 4 weeks
- GitHub stars: 229 (as of 2026-11-24)
- Last push: 2024-08-18

## Often used with
Ajv 100.0%, jsdom 53.4%, js-yaml 36.2%, Prettier 51.7%, uuid 31.0%, fast-xml-parser 31.0%

## Links
- AgentGid page: https://agentgid.com/tools/ajv-formats/
- Homepage: https://github.com/ajv-validator/ajv-formats#readme
- Repository: https://github.com/ajv-validator/ajv-formats


## ajv-formats: check emails, dates and links in form data

ajv-formats is a small free add-on for Ajv, a JavaScript library that checks data against a written set of rules called a JSON Schema. Without it, Ajv cannot check rules such as "this must be an email" or "this must be a date". With it, your app can reject a bad email, an impossible date or a broken link before saving a form.

### Where to use it
- Check sign-up and contact forms: Your server checks that the email, the website address and the date a person typed have the right shape before it saves them.
- Refuse bookings in the past: A booking form accepts only dates from today on, and the same schema gives the error text to show next to the field.
- Check data from an AI model: When a language model returns structured answers, your code checks that the dates, links and IDs in them are well formed before using them. (idea, not from the official pages)
- Match OpenAPI number and data types: If your service is described with OpenAPI, the same checks for 32-bit and 64-bit whole numbers and base64 data run on incoming requests.
- Check server settings files: Before a deploy, a script checks that every host name, IP address and link in a settings file is written correctly. (idea, not from the official pages)

### How to start
- Install Ajv and the formats add-on in your JavaScript project.

```
npm install ajv ajv-formats
```

- Create Ajv and add the formats to it.

```
// ESM/TypeScript import
import Ajv from "ajv"
import addFormats from "ajv-formats"
// Node.js require:
const Ajv = require("ajv")
const addFormats = require("ajv-formats")

const ajv = new Ajv()
addFormats(ajv)
```

- To add only some formats, pass their names.

```
addFormats(ajv, ["date", "time"])
```


### License
Free to use in personal and paid products under the MIT license. Keep the copyright and permission notice with copies of the code.

### Good to know
- It only works together with Ajv version 8; it is not a checker on its own.
- The newest release, 3.0.1, came out on 2024-03-30 and nothing has been released since. In our run it still worked with Ajv 8.20.0.
- Ajv's docs advise against format checks on data from strangers unless you review them, because some patterns can be made to run very slowly.
- Emails and web addresses with non-Latin letters are not covered; a separate add-on handles those.

Checked 2026-11-11 against: https://github.com/ajv-validator/ajv-formats/blob/master/README.md, https://github.com/ajv-validator/ajv-formats/blob/master/LICENSE, https://registry.npmjs.org/ajv-formats/3.0.1, https://registry.npmjs.org/ajv-formats, https://registry.npmjs.org/ajv/latest, https://ajv.js.org/guide/formats.html

### Mistakes to avoid
- Don't: new Ajv().compile({ type: "string", format: "email" }) without ajv-formats, or strict: false to silence the error → Do: Call addFormats(ajv) once on the Ajv instance before compiling schemas that use format (Ajv 7 and newer ship without the formats, and strict: false just skips the format check silently.)
- Don't: addFormats(ajv, { mode: "fast" }) with formatMinimum in the schema → Do: addFormats(ajv, { mode: "fast", keywords: true }), or addFormats(ajv) with no options (With an options object the comparison keywords are added only when keywords is true; in our run Ajv then threw "strict mode: unknown keyword: formatMinimum".)
- Don't: Choosing mode "fast" and trusting it to reject impossible dates → Do: Keep the default full mode when the calendar date must be real (Fast mode checks only the shape; in our run "2026-02-30" passed the date format in fast mode and failed in full mode.)
- Don't: format: "url" in new schemas → Do: format: "uri" (or "uri-reference" for relative links) (The url format is marked deprecated in the format list.)
- Don't: Upgrading ajv in your app and building standalone validation code while ajv-formats still pulls an older ajv → Do: Make sure one ajv version is installed (check the lockfile, or reinstall cleanly) (Standalone code checks that ajv-formats uses the same ajv as your app.)

### Questions
- Why does Ajv say "unknown format" for my schema? Since version 7, Ajv no longer includes the formats; add ajv-formats, or Ajv in strict mode stops at the unknown format.
- Which formats does it add? Dates and times, durations, URIs, email, host names, IPv4 and IPv6, regular expressions, UUIDs, JSON pointers and the OpenAPI number and data types.
- What is the difference between the "full" and "fast" modes? Full is the default. Fast uses simpler patterns and does not check date and time ranges, so February 30 passed in our run.
- Can I use it in a paid product? Yes, it is under the MIT license; keep its notice with copies of the code.

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
