Developer Toolsbeginner

Joi vs Zod

Joi vs Zod compared for 2026: Joi 18.3 (hapi's validator, converts and rejects unknown keys by default, no type inference) vs Zod 4.6 (TypeScript-first, strips unknown keys, infers types). Includes throughput, default behaviour, TypeScript, JSON Schema and bundle size results we measured on 3 December 2026.

Quick Answer

Joi and Zod both describe the shape of data and validate it at runtime, and both now implement Standard Schema and export JSON Schema. They come from different eras. Joi 18.3.2 (4 November 2026) is the hapi project's validator: it converts strings to numbers and dates, rejects unknown object keys and empty strings, checks email TLDs against the IANA list and stops at the first error, all by default. Its validate() result is typed as any, so TypeScript caught none of the four mistakes we planted. Zod 4.6.7 (12 October 2026) is TypeScript-first: z.infer gives you the type, unknown keys are stripped silently, nothing is coerced unless you ask, and every issue is reported. In our runs on 3 December 2026, validating 100,000 valid nested objects took 698-899 ms with Joi and 55-58 ms with Zod (12-15 ms with z.compile). Joi was faster at building schemas and at rejecting bad input when it stops at the first error. Joi's browser build throws on Joi.string().email() unless you pass a tlds option. Pick Zod for TypeScript code and anything shipped to a browser; keep Joi where it already runs, especially in hapi, or when you want strict, converting defaults in plain JavaScript.

Last updated December 3, 2026. Covers Joi 18.3.2 (4 November 2026) and Zod 4.6.7 (12 October 2026); npm registry metadata and download counts, GitHub repositories, Joi milestones and 18.0.0 release notes, Joi API reference, and Zod 4.6 release notes read on 3 December 2026, plus default-behaviour, TypeScript, throughput, bundle and browser-build runs we did that day.

Feature comparison of Joi vs Zod
FeatureJoiZod
Licence & Repository
BSD-3-Clause; hapijs/joi, ~21.2k stars, 217 open issues and PRs
MIT; colinhacks/zod, ~44.6k stars, 136 open issues and PRs
Latest Release
18.3.2 on 4 Nov 2026 (17.13.9 on 28 Oct 2026)
4.6.7 on 12 Oct 2026
npm Weekly Downloads (26 Nov-2 Dec 2026)
25,899,101
359,694,969
Our Run: Install (packages / size)
8 packages, 2.27 MB
1 package, 6.15 MB
Node.js Requirement & Module Format
Node.js >=20; CommonJS with bundled .d.ts; separate browser build
No engines field; ESM with CommonJS entry points, types included
Our Run: TypeScript Inference
validate() value typed any; 0 of 4 planted mistakes caught
z.infer; 2 of 2 planted mistakes caught
Our Run: Unknown Object Keys
Error: "role" is not allowed (stripUnknown / allowUnknown to relax)
Stripped silently (z.strictObject: Unrecognized key)
Our Run: "42" for a Number Field
Converted to 42 (convert: false to reject)
Rejected: expected number, received string (z.coerce.number to convert)
Our Run: Empty String on a Required String
Rejected: "value" is not allowed to be empty
Accepted (add .min(1))
Our Run: [email protected]
Rejected (IANA TLD list); tlds: false to accept
Accepted
Our Run: Errors Reported (default)
First error only (abortEarly: false for all 9)
All issues (3 of 3, 9 of 9)
Our Run: 100k Valid Objects
698-899 ms
55-58 ms (z.compile 12-15 ms)
Our Run: 100k Invalid Objects
136-183 ms first error; 954-1,102 ms all errors
516-725 ms (all errors)
Our Run: Build 10k Schemas
97-108 ms
244-298 ms
Our Run: Browser Bundle (min / gzip)
174,504 B / 55,621 B
89,974 B / 26,195 B (import * as z); zod/mini 15,843 B / 5,529 B
Our Run: Browser Build Behaviour
email() throws unless tlds: false or an allow list
Same behaviour as Node.js
JSON Schema Export
schema['~standard'].jsonSchema.input() / output() (draft 2020-12), since 18.1.0
z.toJSONSchema() (draft 2020-12) and z.fromJSONSchema()
Standard Schema
Yes, since 18.0.0 (vendor joi)
Yes (vendor zod)
Async Rules
external() rules; validate() throws, validateAsync() required
Async refine/transform; parse() throws $ZodAsyncError, parseAsync() required
Release Activity & Support
18.x patches through 2026 (18.3.2 Nov); 17.x still patched
4.6.0-4.6.7 Sep-Oct 2026; canary builds published

Joi

Joi is the schema description language and validator from the hapi ecosystem, in use since 2012. You build schemas with chained calls such as Joi.object({ email: Joi.string().email().required() }) and call schema.validate(value) or validateAsync(). Its defaults lean strict and helpful at the same time: convert is on, so the string "42" becomes the number 42 and date strings become Date objects; unknown object keys are errors unless you set allowUnknown or stripUnknown; empty strings fail a string schema; email() checks the top-level domain against the IANA registry; and abortEarly stops at the first error. Joi 18.0.0 (3 August 2025) dropped Node.js versions below 20 and added Standard Schema support, 18.1.0 (23 March 2026) added JSON Schema output through schema['~standard'].jsonSchema, and 18.2.0 (4 May 2026) added a recursion limit for linked schemas. Several 2026 patch releases closed prototype-pollution paths around __proto__ in messages and renames. Joi ships TypeScript declarations, but they describe the API, not your data: the validated value is any unless you pass a type yourself, and that type is not checked against the schema. The 17.x line still receives patches (17.13.9 on 28 October 2026).

Pros

  • Strict defaults out of the box: unknown keys, empty strings and bad email TLDs were all rejected without extra options
  • Converts input by default ("42" to 42, "true" to true, date strings to Date), which suits query strings and form posts
  • Fast to build schemas: 10,000 small object schemas in 97-108 ms against 244-298 ms for Zod
  • Stops at the first error by default, so rejecting 100,000 bad objects took 136-183 ms
  • Mature extension API, references, conditional rules (when) and readable default messages such as "role" is not allowed
  • Standard Schema and JSON Schema output since 18.0 and 18.1

Cons

  • No type inference: validate() returned any and tsc 6.0.3 caught 0 of 4 planted mistakes, including a misspelled key
  • Slow on the happy path: 698-899 ms for 100,000 valid objects against 55-58 ms for Zod
  • Browser build throws "Built-in TLD list disabled" when you call email() without a tlds option
  • Larger browser bundle than Zod's namespace or Mini imports: 174,504 B minified, 55,621 B gzipped for a three-field schema
  • CommonJS package whose types reference Buffer, so strict TypeScript projects need @types/node

Best For

Existing hapi and Express codebases, plain-JavaScript services that validate query strings and form input, and teams that want strict, converting defaults without writing extra options.

Zod

Zod is a TypeScript-first schema library: you declare z.object({ email: z.email(), age: z.number().int() }), call parse() or safeParse(), and get both runtime checks and a static type through z.infer. Zod 4 reorganised the package into a classic API, a tree-shakable zod/mini functional API and a shared core, and added JSON Schema conversion with z.toJSONSchema(). Recent 4.x minors added compiled schemas (z.compile in 4.5), .validate() for a yes/no check without building a result, fromJSONSchema() improvements and z.iban() in 4.6.0 (9 September 2026), and z.currencyCode() plus a faster z.url() in 4.6.4. Zod's defaults are permissive about shape and strict about types: unknown object keys are stripped without an error (z.strictObject rejects them), strings are never coerced to numbers unless you use z.coerce, and every issue is collected rather than stopping at the first. The 4.6.6 release notes disclose that six malicious commits pushed with a compromised credential on 21 September were reverted the same day and never published to npm. The package has no dependencies, is ESM with CommonJS entry points, and implements Standard Schema, so libraries such as form resolvers and API frameworks accept it directly.

Pros

  • Types from the schema: z.infer caught both planted mistakes (a misspelled key and a wrong type) in tsc 6.0.3
  • Fast on valid input: 100,000 nested objects in 55-58 ms, 12-15 ms with z.compile
  • Reports every issue by default (all 9 on our bad object) with paths and codes
  • Small browser bundles if you import it right: 89,974 / 26,195 B with import * as z, 15,843 / 5,529 B with zod/mini
  • Zero dependencies, one package, JSON Schema export with a $schema draft 2020-12 header
  • Most-used validator on npm: 359,694,969 downloads in the week to 2 December 2026

Cons

  • Strips unknown keys silently by default; mass-assignment protection needs z.strictObject or awareness that data is filtered
  • import { z } from 'zod' pulled every locale into our bundle: 453,997 B minified, 92,414 B gzipped
  • No coercion unless asked, and z.coerce.boolean() turns the string "false" into true
  • Slower to build schemas (244-298 ms for 10,000) and to reject bad input when you only need the first error (516-725 ms per 100,000)
  • Accepts empty strings and any syntactically valid email domain unless you add .min(1) or your own TLD rule

Best For

TypeScript applications, shared front-end and back-end schemas, form libraries, tRPC-style APIs and anything that needs inferred types or a small browser bundle.

Same job, opposite defaults

We validated the same user schema (email, integer age of at least 18, name) with Joi 18.3.2 and Zod 4.6.7 on 3 December 2026 and fed both the same awkward inputs. An extra role: 'admin' key made Joi fail with "role" is not allowed, while Zod returned the object with role removed and no error. A string age of "42" passed Joi as the number 42 and failed Zod with expected number, received string. An empty name failed Joi ("value" is not allowed to be empty) and passed Zod. The address [email protected] failed Joi, which checks TLDs against the IANA list, and passed Zod. An object with three problems produced one Joi message ("email" must be a valid email) and three Zod issues; Joi lists all nine on our larger test object only with abortEarly: false. Neither default is wrong. Joi assumes untrusted, stringly typed input such as query strings and wants it converted and policed. Zod assumes typed JSON and wants the output to match a TypeScript type, which is why it filters extra keys instead of rejecting them. The practical risk is in migration: moving a Joi schema to Zod quietly turns unknown-key errors into stripped fields and conversions into type errors.

What we measured: throughput, schema build and bundle size

Benchmarks ran on Node.js 22.23.5 in a 2-vCPU sandbox, pinned to one core, three runs. The schema had seven fields including a nested address, an array of strings, a regex and a boolean. Validating 100,000 valid objects took 698-899 ms with Joi, 55-58 ms with Zod and 12-15 ms with a z.compile()d Zod schema. Invalid objects with nine problems each reversed part of the picture: Joi stops at the first error by default and finished in 136-183 ms; with abortEarly: false it took 954-1,102 ms, against 516-725 ms for Zod, which always collects every issue. Building 10,000 small object schemas took 97-108 ms with Joi and 244-298 ms with Zod, which matters if you create schemas per request. Loading the library cost about the same: require() took 33-57 ms for Joi and 37-68 ms for Zod, with 46-48 MB resident memory either way. With esbuild 0.28.2 minifying a three-field schema for the browser, Joi's bundle was 174,504 B (55,621 B gzipped). Zod depended on how we imported it: import { z } produced 453,997 B (92,414 B gzipped) because the locale files came along, import * as z produced 89,974 B (26,195 B), and zod/mini 15,843 B (5,529 B).

TypeScript: inference versus annotations

This is the gap that decides most new projects. We wrote a file with deliberate mistakes and ran tsc 6.0.3 in strict mode. With Zod, const u = schema.parse(input) is typed from the schema, so reading u.agee failed with Property 'agee' does not exist (Did you mean 'age'?) and assigning u.age to a string failed with a type error: two mistakes, two errors. With Joi, the value returned by validate() is any, so the same two mistakes compiled. Joi lets you write Joi.object<User>({...}), but the generic is trusted, not checked: a schema declaring age as Joi.string() typed against an interface where age is a number compiled cleanly, and so did a Joi.ObjectSchema<User> annotation on a schema with a misspelled agee key. That made 0 of 4 for Joi. Joi's declaration file also references Buffer, so a strict project without @types/node got three TS2591 errors from node_modules. If you keep Joi in TypeScript, define the interface once, annotate schemas with it and test the schemas, because the compiler will not keep the two in sync. Zod removes that duplication, and its Standard Schema support means libraries such as form resolvers accept the schema without an adapter.

Browser builds, async rules and JSON Schema

Joi publishes a separate browser build (dist/joi-browser.min.js), and bundlers pick it through the package's browser field. That build leaves out the IANA TLD list, and it does not fall back quietly: calling Joi.string().email() threw AssertError: Built-in TLD list disabled when the schema was created, so our bundled page failed at load. Passing { tlds: false } or { tlds: { allow: ['com'] } } fixed it. Zod behaves the same in Node.js and the browser. Both libraries separate sync and async work and fail loudly when you mix them up: a Joi schema with an external() rule threw Schema with external rules must use validateAsync() from validate(), and a Zod schema with an async refine threw $ZodAsyncError from parse() and worked with parseAsync(). Both now emit JSON Schema draft 2020-12. Joi's output (from schema['~standard'].jsonSchema.input(), added in 18.1.0) encodes its defaults: required strings carry minLength 1 and objects carry additionalProperties false. Zod's z.toJSONSchema() added a $schema header, its email regex as a pattern and a safe-integer maximum on integers. Both expose a ~standard property, so frameworks that accept Standard Schema take either library.

Limits and alternatives

Some of Zod's defaults need care. Silently stripped keys mean a client sending userName instead of username gets a successful parse with the field missing; use z.strictObject for request bodies where that matters. z.coerce.boolean() follows JavaScript truthiness, so the string "false" became true in our run; z.stringbool() is the parser for "true"/"false"/"yes" style input. Dates need the same thought in both libraries: Joi converted '2/31/2019' to 2 March 2019, and so did z.coerce.date(), while z.iso.date() rejected '2019-02-31'. Joi's limits are mostly about TypeScript and the front end: no inference, a larger browser bundle and the TLD assertion. Its maintainers keep shipping fixes, including 2026 patches for prototype-pollution paths around __proto__ and linear-time fixes for unique() and multiple-email parsing, and the 17.x line is still patched. If you mainly need a small bundle, Valibot is the usual alternative to Zod; see our Zod vs Valibot and Zod vs Yup comparisons. In Python services the same split shows up as Pydantic versus Marshmallow. For Joi users on hapi, staying put is reasonable: the framework integrates it directly and nothing here forces a rewrite.

Verdict

Pick Zod for new TypeScript code. The schema is the type, it validated valid data more than ten times faster than Joi in our runs, and its namespace and Mini imports produced much smaller browser bundles. Use z.strictObject (or check for extra keys) wherever silently dropped fields would hide a client bug, add .min(1) to required strings, and import * as z rather than { z } if bundle size matters. Pick Joi, or keep it, when you run hapi, when the code is plain JavaScript, or when the input is mostly query strings and form posts that you want converted and strictly checked with no extra configuration. Joi's first-error default also makes it cheap at rejecting junk. Do not migrate a working Joi codebase just for speed unless validation shows up in your profiles; do migrate when you want types from your schemas, because Joi's typings will not catch a misspelled field. If Joi has to run in the browser, pass a tlds option to every email() call.

All Comparisons

Joi vs Zod — FAQ

Common questions answered from the comparison above

Should I use Joi or Zod in 2026?

Zod for TypeScript projects and anything that runs in the browser: it infers types from schemas, validated valid data 12-16 times faster in our test and bundles smaller with import * as z or zod/mini. Joi remains a good fit for hapi and plain-JavaScript services that want strict, converting defaults.

Is Zod faster than Joi?

On valid data, yes: 55-58 ms against 698-899 ms for 100,000 nested objects in our run, and 12-15 ms with z.compile. Joi was faster at building schemas (97-108 ms against 244-298 ms for 10,000) and at rejecting invalid data when it stops at the first error (136-183 ms).

Does Joi support TypeScript type inference?

No. Joi ships declarations for its API, but validate() returns any. You can pass an interface as a generic, but Joi does not check it against the schema; in our test a schema with a wrong field type and one with a misspelled key both compiled.

Why does Zod strip unknown keys while Joi rejects them?

Different defaults. Joi rejects unknown keys unless you set allowUnknown or stripUnknown. Zod's z.object strips them so the output matches the inferred type; use z.strictObject to reject them or z.looseObject to keep them.

Can Joi and Zod generate JSON Schema?

Yes. Joi 18.1.0 added schema['~standard'].jsonSchema.input() and output(), and Zod 4 has z.toJSONSchema(); both target draft 2020-12. Both also implement Standard Schema.

Why does Joi email() throw in the browser?

Joi's browser build excludes the IANA TLD list, and email() without a tlds option asserts Built-in TLD list disabled when the schema is created. Pass { tlds: false } or an allow list.

Get the next comparison by email

One email a week: new and trending developer tools, fresh comparisons, and what shipped. Unsubscribe in one click.