{
 "kind": "tool",
 "slug": "zod",
 "path": "tools/zod/",
 "name": "Zod",
 "maker": null,
 "density": "full",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "Forms, validation and schemas",
   "tools/forms-validation/"
  ]
 ],
 "lead": "Check incoming data in TypeScript apps.",
 "chips": [
  {
   "label": "Forms, validation and schemas",
   "path": "tools/forms-validation/"
  },
  {
   "label": "NPM"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "npm install zod"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/colinhacks/zod"
  },
  {
   "label": "Website",
   "href": "https://zod.dev"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "MIT",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": "Permission is hereby granted, free of charge, to any person obtaining a copy",
   "note": "MIT allows use in paid and closed-source products.",
   "src": "https://github.com/colinhacks/zod/blob/main/LICENSE"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change Nov 22, 2026",
   "note": "Latest GitHub release Oct 12, 2026. ",
   "src": "https://github.com/colinhacks/zod"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "1,582 projects",
   "status": "info",
   "sub": "#1 of 63 in its category",
   "note": "Dependency in 1,582 public GitHub projects set up for AI coding agents that we scanned (25.3%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Docs for agents",
   "status": "yes",
   "sub": "llms.txt",
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": "https://zod.dev/llms.txt"
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily; card checked Nov 10, 2026.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What Zod does",
   "parts": [
    {
     "t": "prose",
     "text": "Zod is a free TypeScript library that checks data before your app trusts it, such as form fields, settings or replies from other services. You describe once what the data must look like, and Zod either hands back clean data or says exactly which field is wrong. It runs on the server and in the browser."
    },
    {
     "t": "h3",
     "text": "What people build with it"
    },
    {
     "t": "uses",
     "items": [
      {
       "title": "Check sign-up forms on the server",
       "text": "A visitor sends an email, an age and a plan; your server accepts the request only when every field fits the rules.",
       "idea": false
      },
      {
       "title": "Show the error next to each field",
       "text": "When a form is wrong, your page shows \"Invalid email address\" under the email box instead of one vague message.",
       "idea": false
      },
      {
       "title": "Tell an AI model what to return",
       "text": "Describe the answer you want from a language model once, send that description with the request, then check the reply before you use it.",
       "idea": false
      },
      {
       "title": "Quick yes-or-no check on big uploads",
       "text": "When a large file or request only needs a pass or fail answer, a cheaper check skips building the full list of problems.",
       "idea": false
      },
      {
       "title": "Refuse to start with broken settings",
       "text": "Your app reads its port and database address at start-up and stops with a clear message if one is missing or wrong.",
       "idea": true
      },
      {
       "title": "Check replies from other services",
       "text": "Before your app saves data fetched from a payment or shipping service, make sure the fields you rely on are really there.",
       "idea": true
      }
     ]
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "Zod popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "89",
       "of": "/ 100",
       "l": "Gid Score, #11 overall"
      },
      {
       "n": "471M",
       "l": "downloads a week, npm"
      },
      {
       "n": "44.4K",
       "l": "GitHub stars"
      },
      {
       "n": "1,582",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How Zod is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "Zod is a dependency in 1,582 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (32.5% of the 4,867 JavaScript/TypeScript ones), #1 of 63 in forms, validation and schemas.",
      "Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 5,755; those are left out of every share on this page.",
      "The most used alternative in our scan is Ajv (154 projects).",
      "Projects that use it most often also use TypeScript (93.5%), React Hook Form Resolvers (31.1%), clsx (47.9%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "867 projects, 26.5%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "719 projects, 29.4%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "711 projects, 23.4%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "137 projects, 28.9%",
       "v": "Gemini CLI",
       "path": "agents/gemini-cli/"
      },
      {
       "l": "128 projects, 27.3%",
       "v": "OpenAI Codex",
       "path": "agents/openai-codex/"
      },
      {
       "l": "97 projects, 28.3%",
       "v": "OpenCode",
       "path": "agents/opencode/"
      },
      {
       "l": "77 projects, 23.1%",
       "v": "OpenClaw",
       "path": "agents/openclaw/"
      },
      {
       "l": "75 projects, 26.9%",
       "v": "Devin Desktop",
       "path": "agents/devin-desktop/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 93.5% of its projects",
       "v": "TypeScript",
       "path": "tools/typescript/"
      },
      {
       "l": "In 31.1% of its projects",
       "v": "React Hook Form Resolvers",
       "path": "tools/hookform/"
      },
      {
       "l": "In 47.9% of its projects",
       "v": "clsx",
       "path": "tools/clsx/"
      },
      {
       "l": "In 47.2% of its projects",
       "v": "Tailwind Merge",
       "path": "tools/tailwind-merge/"
      },
      {
       "l": "In 32.5% of its projects",
       "v": "React Hook Form",
       "path": "tools/react-hook-form/"
      },
      {
       "l": "In 61.1% of its projects",
       "v": "React",
       "path": "tools/react/"
      },
      {
       "l": "In 48.2% of its projects",
       "v": "Lucide React",
       "path": "tools/lucide-react/"
      },
      {
       "l": "In 42.8% of its projects",
       "v": "Class Variance Authority",
       "path": "tools/class-variance-authority/"
      }
     ]
    }
   ]
  },
  {
   "id": "profile",
   "nav": "Profile",
   "h2": "Zod in practice",
   "parts": [
    {
     "t": "h3",
     "text": "Strengths"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "The schema is the type",
       "v": "<code>z.infer&lt;typeof Schema&gt;</code> extracts a static type from a schema, so you don't write the type twice. When a <code>.transform()</code> changes the type, <code>z.input</code> and <code>z.output</code> give you each side separately."
      },
      {
       "l": "Opt-in compiled fast path",
       "v": "<code>z.compile(schema)</code> returns a clone with an ahead-of-time compiled path for valid inputs. Invalid inputs fall back to the regular parser, so error output stays the same. The README reports a median 2.4x speedup across a 55-schema benchmark. It says gains grow with how much work each parse does, and a bare <code>z.string()</code> gains nothing."
      },
      {
       "l": "Zod Mini for tight bundles",
       "v": "<code>zod/mini</code> maps one-to-one to the main API but uses wrapper functions such as <code>z.optional(z.string())</code> instead of methods. The maintainer says this makes it easier for bundlers to drop the parts you don't use."
      },
      {
       "l": "Lighter on the TypeScript compiler",
       "v": "The release notes give a sample file that produced more than 25000 type instantiations under Zod 3 and about 175 under Zod 4. In the same notes, a long chain of <code>.extend()</code> and <code>.omit()</code> calls compiled in 400ms, down from 4000ms."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Watch out for"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Strict mode is mandatory",
       "v": "The docs require <code>\"strict\": true</code> in <code>tsconfig.json</code>. Only TypeScript v5.5 and later is officially supported."
      },
      {
       "l": "Compilation needs new Function",
       "v": "<code>z.compile()</code> relies on <code>new Function</code>. Global compile mode switches off when <code>z.config({ jitless: true })</code> is set, for example in CSP environments."
      },
      {
       "l": "Async schemas stay uncompiled",
       "v": "Schemas with async refinements or transforms are handed back unchanged and keep using the regular parser. Pass <code>{ strict: true }</code> if you want an error thrown instead."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Infer a type from a schema"
    },
    {
     "t": "tabs",
     "label": "Example",
     "items": [
      {
       "tab": "Ts",
       "code": "const Player = z.object({\n  username: z.string(),\n  xp: z.number(),\n});\n\n// extract the inferred type\ntype Player = z.infer<typeof Player>;\n\n// use it in your code\nconst player: Player = { username: \"billie\", xp: 100 };"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "profile",
   "h2": "More about Zod",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Funding",
       "path": "tools/funding/",
       "items": [
        "GitHub Sponsors: https://github.com/colinhacks",
        "58 GitHub sponsors"
       ]
      },
      {
       "title": "Head to head",
       "items": [
        {
         "text": "Zod vs Ajv",
         "note": "used together in 79 projects",
         "path": "tools/compare/zod-vs-ajv/"
        }
       ]
      },
      {
       "title": "Packages around it",
       "items": [
        "class-variance-authority: Component variant classes",
        "tailwind-merge: Tailwind class conflict merging",
        "clsx: Conditional className strings",
        "react-hook-form: Hook-based form state",
        "@radix-ui: Unstyled UI primitives",
        "typescript: Typed JavaScript"
       ]
      },
      {
       "title": "More in Forms, validation and schemas",
       "path": "tools/forms-validation/",
       "items": [
        {
         "text": "React Hook Form",
         "path": "tools/react-hook-form/"
        },
        {
         "text": "Pydantic",
         "path": "tools/pydantic/"
        },
        {
         "text": "React Hook Form Resolvers",
         "path": "tools/hookform/"
        },
        {
         "text": "jsonschema",
         "path": "tools/jsonschema/"
        },
        {
         "text": "ajv-formats",
         "path": "tools/ajv-formats/"
        },
        {
         "text": "zod-to-json-schema",
         "path": "tools/zod-to-json-schema/"
        },
        {
         "text": "Protocol Buffers",
         "path": "tools/protobuf/"
        },
        {
         "text": "email-validator",
         "path": "tools/email-validator/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "Zod",
       "me": true,
       "facts": [
        "MIT",
        "Gid 89",
        "471M/wk"
       ]
      },
      {
       "name": "Pydantic",
       "why": "Pick Pydantic when your back end is written in Python; it checks data using Python type hints.",
       "path": "tools/pydantic/",
       "facts": []
      },
      {
       "name": "Ajv",
       "why": "Pick Ajv when your rules already exist as JSON Schema files that you check against at run time.",
       "path": "tools/ajv/",
       "facts": [
        "MIT",
        "Gid 78",
        "547M/wk"
       ]
      },
      {
       "name": "Valibot",
       "why": "Pick Valibot when you want a modular schema library built from small separate functions.",
       "path": "tools/valibot/",
       "facts": [
        "MIT",
        "Gid 68",
        "36M/wk"
       ]
      },
      {
       "name": "TypeBox",
       "why": "JSON Schema type builder with static type resolution for TypeScript validation.",
       "path": "tools/sinclair-typebox/",
       "facts": [
        "MIT",
        "Gid 58",
        "17M/wk"
       ]
      },
      {
       "name": "Yup",
       "why": "Simple schema validation library for JavaScript with chainable API and error handling.",
       "path": "tools/yup/",
       "facts": [
        "MIT",
        "Gid 69",
        "16.6M/wk"
       ]
      }
     ],
     "more": "Compare Zod with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "prompt",
     "text": "Use Zod (pin zod@4.6.7, TypeScript 5.5+ with strict mode) to validate every request body and form in this app with safeParse, show per-field messages from z.flattenError, and use the Zod 4 API (z.email(), z.strictObject(), error.issues)."
    },
    {
     "t": "steps",
     "items": [
      {
       "text": "Add Zod to your project.",
       "code": "npm install zod",
       "src": "https://zod.dev/"
      },
      {
       "text": "Describe the data once, then parse incoming data with it. Valid data comes back typed; bad data throws an error that lists every problem.",
       "code": "import * as z from \"zod\";\n\nconst Player = z.object({\n  username: z.string(),\n  xp: z.number()\n});\n\nPlayer.parse({ username: \"billie\", xp: 100 });\n",
       "src": "https://zod.dev/basics"
      },
      {
       "text": "Turn on strict mode in tsconfig.json; Zod expects it.",
       "code": "{\n  \"compilerOptions\": {\n    \"strict\": true\n  }\n}\n",
       "src": "https://zod.dev/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Rules for your agent"
    },
    {
     "t": "rules",
     "label": "Paste into AGENTS.md or CLAUDE.md",
     "text": "## Zod\n- Set `\"strict\": true` in `tsconfig.json` and target TypeScript v5.5 or later.\n- Derive types with `z.infer<typeof Schema>` (or `z.input` / `z.output` when a `.transform()` changes the type) instead of writing them by hand.\n- Use `.safeParse()` to get a result object instead of wrapping `.parse()` in `try/catch`. Switch to `.parseAsync()` / `.safeParseAsync()` when a schema has async refinements or transforms.\n- In Zod 4, prefer top-level formats like `z.email()`, `z.uuid()` and `z.ipv4()` over the deprecated `z.string().email()` method forms.\n- In Zod 4, customize errors with the `error` param, not `message`. Use `z.treeifyError()` instead of the deprecated `.format()` / `.flatten()`.\n- When using `z.compile()`, compile the final schema. Calling `.refine()`, `.extend()` and similar on a compiled schema returns an uncompiled one.\n- For apps with strict bundle-size limits, import from `zod/mini` and add checks with `.check()`.\n"
    },
    {
     "t": "h3",
     "text": "Mistakes to avoid"
    },
    {
     "t": "mistakes",
     "items": [
      {
       "dont": "z.string().email(), z.string().uuid(), z.string().url()",
       "fix": "z.email(), z.uuid(), z.url()",
       "why": "In Zod 4 string formats moved to the top level; the old methods still run in 4.6.7 but are deprecated."
      },
      {
       "dont": "z.object({...}).strict() or .passthrough()",
       "fix": "z.strictObject({...}) or z.looseObject({...})",
       "why": "Zod 4 deprecates the two methods in favour of top-level functions."
      },
      {
       "dont": "result.error.errors",
       "fix": "result.error.issues",
       "why": ".errors was removed in Zod 4; in our run it was undefined while .issues held the problem."
      },
      {
       "dont": "z.object({ port: z.coerce.number() }) and expecting a missing key to pass",
       "fix": "z.coerce.number().default(3000) when the key may be absent",
       "why": "In Zod 4 a missing key with a coerce field is an error, unlike Zod 3."
      },
      {
       "dont": "Calling z.compile() or importing \"zod/compile\" on a page with a strict Content Security Policy",
       "fix": "Leave compilation off there, or set z.config({ jitless: true }) so global mode stands down",
       "why": "Compilation builds code with new Function, which strict CSP pages block."
      }
     ]
    }
   ]
  },
  {
   "id": "faq",
   "nav": "Questions",
   "h2": "Questions",
   "parts": [
    {
     "t": "faq",
     "items": [
      {
       "q": "Do I need TypeScript to use it?",
       "a": "No. It works with TypeScript and with plain JavaScript; with TypeScript it also gives you the data's type for free.",
       "evidence": {
        "url": "https://zod.dev/",
        "quote": "Works with TypeScript and plain JS"
       }
      },
      {
       "q": "Which TypeScript version does it need?",
       "a": "Zod is tested with TypeScript 5.5 and later, with strict mode turned on.",
       "evidence": {
        "url": "https://zod.dev/",
        "quote": "Zod is tested against TypeScript v5.5 and later."
       }
      },
      {
       "q": "Can I turn my rules into JSON Schema for an AI model or an API description?",
       "a": "Yes, z.toJSONSchema() converts a schema; a few kinds of rules have no JSON Schema equivalent.",
       "evidence": {
        "url": "https://zod.dev/json-schema",
        "quote": "To convert a Zod schema to JSON Schema, use the z.toJSONSchema() function."
       }
      },
      {
       "q": "Is Zod 3 still maintained?",
       "a": "The docs call Zod 3 functionally end-of-life with no new features; new projects should use version 4.",
       "evidence": {
        "url": "https://zod.dev/library-authors",
        "quote": "Zod 3 is functionally end-of-life and won't receive new features."
       }
      }
     ]
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "npm zod"
  ],
  [
   "Category",
   "Forms, validation and schemas"
  ],
  [
   "License",
   "MIT"
  ],
  [
   "Latest version",
   "v4.6.5, September 13, 2026"
  ],
  [
   "On GitHub since",
   "March 2020"
  ],
  [
   "Gid Score",
   "89.2"
  ],
  [
   "Rank in category",
   "#1 of 63"
  ],
  [
   "GitHub",
   "colinhacks/zod"
  ],
  [
   "Last change",
   "Nov 22, 2026"
  ]
 ],
 "good": [
  "It has no other packages inside and runs both on servers and in modern browsers.",
  "Version 4 changed many names and behaviours from version 3, and older tutorials still show the old ones.",
  "The full check reports every problem, so a huge bad input means a huge error list; cap sizes or use the yes-or-no check."
 ],
 "checked_line": "Read by AgentGid from 15 official pages, card checked Nov 10, 2026; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/colinhacks.png"
}