Parsing a value to match the schema. This is different to validation because it returns a new value.
Copy to clipboardimport * as v from "valibot"; import { personSchema } from "./schemas"; const person = v.parse(personSchema, data); // person is of type Person
| Library | Version | /wk | Optimizations | Error type | Mean | Compare | ||||
|---|---|---|---|---|---|---|---|---|---|---|
@railway-ts/pipelines | Code snippet | 0.1.29 | 123 | None | Abort early | 649 ns | ||||
valibot | Code snippet | 1.4.2 | 14.88M | None | Abort early | 743 ns | 1.15x | |||
effect@beta | Code snippet(Commented code is not benchmarked) | 4.0.0-beta.101 | 24.3M | None | Abort early | 1 μs | 1.98x | |||
@paseri/paseri (safeParse) | Code snippet | 1.9.7 | 172 | None | All errors | 4 μs | 5.99x | |||
joi | Code snippet | 18.2.3 | 20.46M | None | Abort early | 4 μs | 6.08x | |||
io-ts | Code snippet | 2.2.22 | 2.26M | None | All errors | 5 μs | 8.4x | |||
effect | Code snippet(Commented code is not benchmarked) | 3.22.0 | 24.3M | None | Abort early | 10 μs | 15.95x | |||
@paseri/paseri (parse) | Code snippet | Throws on invalid dataThis library throws an error when parsing invalid data (and has no non-throwing equivalent), so the benchmark includes a try/catch. | 1.9.7 | 172 | None | All errors | 11 μs | 16.67x | ||
superstruct | Code snippet | 2.0.2 | 5.02M | None | Abort early | 11 μs | 16.92x | |||
superstruct (schema.validate) | Code snippet | 2.0.2 | 5.02M | None | Abort early | 11 μs | 17.4x | |||
effect@beta | Code snippet(Commented code is not benchmarked) | 4.0.0-beta.101 | 24.3M | None | All errors | 21 μs | 32.86x | |||
valibot | Code snippet | 1.4.2 | 14.88M | None | All errors | 30 μs | 45.79x | |||
valibot (abortPipeEarly only) | Code snippet | 1.4.2 | 14.88M | None | Abort early | 30 μs | 45.99x | |||
@railway-ts/pipelines | Code snippet | 0.1.29 | 123 | None | All errors | 32 μs | 48.71x | |||
effect | Code snippet(Commented code is not benchmarked) | 3.22.0 | 24.3M | None | All errors | 32 μs | 49.12x | |||
zod/v3 | Code snippet | 4.4.3 | 223.55M | None | All errors | 42 μs | 65.47x | |||
joi | Code snippet | 18.2.3 | 20.46M | None | All errors | 62 μs | 95.79x | |||
zod/mini (jitless) | Code snippet | 4.4.3 | 223.55M | None | All errors | 67 μs | 103.47x | |||
decoders | Code snippet | 2.9.3 | 24.27K | None | All errors | 67 μs | 103.48x | |||
superstruct | Code snippet | 2.0.2 | 5.02M | None | All errors | 78 μs | 120.01x | |||
superstruct | Code snippet | 2.0.2 | 5.02M | None | All errors | 78 μs | 120.73x | |||
zod (jitless) | Code snippet | 4.4.3 | 223.55M | None | All errors | 84 μs | 129.14x | |||
yup | Code snippet | Throws on invalid dataThis library throws an error when parsing invalid data (and has no non-throwing equivalent), so the benchmark includes a try/catch. | 1.7.1 | 10.52M | None | Abort early | 101 μs | 155.19x | ||
runtypes | Code snippet | 7.0.5 | 190.07K | None | Abort early | 183 μs | 281.64x | |||
runtypes | Code snippet | Throws on invalid dataThis library throws an error when parsing invalid data (and has no non-throwing equivalent), so the benchmark includes a try/catch. | 7.0.5 | 190.07K | None | Abort early | 199 μs | 306.82x | ||
@sapphire/shapeshift | Code snippet | Throws on invalid dataThis library throws an error when parsing invalid data (and has no non-throwing equivalent), so the benchmark includes a try/catch. | 5.0.0 | 1.06M | None | All errors | 324 μs | 499.65x | ||
@sapphire/shapeshift (run) | Code snippet | 5.0.0 | 1.06M | None | All errors | 332 μs | 511.14x | |||
yup | Code snippet | Throws on invalid dataThis library throws an error when parsing invalid data (and has no non-throwing equivalent), so the benchmark includes a try/catch. | 1.7.1 | 10.52M | None | All errors | 613 μs | 944.82x | ||