Many libraries implement the Standard Schema interface, which allows many other libraries to accept them without needing to specialise for each library.
Copy to clipboardimport { personSchema } from "./schemas"; const person = await upfetch(url, { schema: personSchema, });
Copy to clipboardimport { personSchema } from "./schemas"; const person = await upfetch(url, { schema: personSchema });
We benchmark the time taken to parse using a standard schema.
Info
Some libraries require an adapter before they can be used as a standard schema. The time to convert the schema is not measured, only the time to parse using it.
Optimizations
Abort early
| Library | Version | /wk | Optimizations | Error type | Mean | Compare | |||
|---|---|---|---|---|---|---|---|---|---|
ata-validator | Code snippet | 1.63.1 | 53.34K | JIT | All errors | 2 μs | |||
sury | Code snippet | 11.1.0 | 409.26K | JIT | All errors | 3 μs | 1.28x | ||
zod | Code snippet | 4.6.7 | 454.84M | JIT | All errors | 9 μs | 4.35x | ||
zod (compile) | Code snippet(Setup code is not benchmarked) | 4.6.7 | 454.84M | JIT | All errors | 9 μs | 4.38x | ||
zod/mini | Code snippet | 4.6.7 | 454.84M | JIT | All errors | 12 μs | 6.07x | ||
zod/mini (compile) | Code snippet(Setup code is not benchmarked) | 4.6.7 | 454.84M | JIT | All errors | 12 μs | 6.3x | ||
arktype | Code snippet | 2.2.9 | 2.87M | JIT | All errors | 55 μs | 27.65x | ||