LogoLogo

Schema Benchmarks

    • home
      Home

    • download_2
      Download
    • timer
      Initialization
    • check_circle
      Validation
    • output_circle
      Parsing

    • article
      Blog
Code styleCode style
Normal styleNormal style
System themeSystem theme
Light themeLight theme
Dark themeDark theme
Expand sidebarExpand sidebar
Benchmarks/ParsingParsing
Code styleCode style
Normal styleNormal style
System themeSystem theme
Light themeLight theme
Dark themeDark theme
github
GitHubGitHub

Parsing a value to match the schema. This is different to validation because it returns a new value.

import * as v from "valibot";
import { personSchema } from "./schemas";

const person = v.parse(personSchema, data);
// person is of type Person
Data
errorInvalidcheck_circleValid
Optimizations
flash_offNonecodeJITbuildPrecompiled
Abort early
errorAll errorswarningAbort early
LibrarysortVersionDownloads (/wk)sortOptimizationsError typeMeanarrow_upwardCompare
valibot
Code snippet
v.safeParse(schema, data, { abortEarly: true })
1.2.05.6MNoneAbort early745 ns
joi
Code snippet
schema.validate(data, { abortEarly: true })
18.0.216MNoneAbort early4 μs
5.24x
stat_minus_1
typia (createValidate)
Code snippet
// const validate = typia.createValidate<TypiaSchema>();
validate(data);

(Commented code is not benchmarked)

11.0.3237KPrecompiledAll errors7 μs
8.95x
stat_minus_1
typia (validate)
Code snippet
typia.validate<TypiaSchema>(data)
11.0.3237KPrecompiledAll errors7 μs
9.29x
stat_minus_1
sury (compile)
Code snippet
// const compile = S.compile(S.schema(...));
compile(data);

(Commented code is not benchmarked)

Throws on invalid data
This library throws an error when parsing invalid data (and has no non-throwing equivalent), so the benchmark includes a try/catch.
11.0.0-alpha.466KJITAll errors8 μs
10.4x
stat_minus_1
sury (compile + safe)
Code snippet
// const compile = S.compile(S.schema(...));
S.safe(() => compile(data));

(Commented code is not benchmarked)

11.0.0-alpha.466KJITAll errors8 μs
10.7x
stat_minus_1
sury
Code snippet
S.parseOrThrow(data, schema)
Throws on invalid data
This library throws an error when parsing invalid data (and has no non-throwing equivalent), so the benchmark includes a try/catch.
11.0.0-alpha.466KJITAll errors8 μs
10.99x
stat_minus_1
sury (safe)
Code snippet
S.safe(() => S.parseOrThrow(data, schema))
11.0.0-alpha.466KJITAll errors8 μs
11.24x
stat_minus_1
effect
Code snippet
// const decodeFirst = Schema.decodeUnknownEither(
//  schema, 
//  { errors: "first" }
// );
decodeFirst(data)

(Commented code is not benchmarked)

3.19.177.1MNoneAbort early9 μs
12.27x
stat_minus_1
valibot (abortPipeEarly only)
Code snippet
v.safeParse(schema, data, { abortPipeEarly: true })
1.2.05.6MNoneAbort early28 μs
38.03x
stat_minus_1
valibot
Code snippet
v.safeParse(schema, data)
1.2.05.6MNoneAll errors28 μs
38.13x
stat_minus_1
effect
Code snippet
// const decodeAll = Schema.decodeUnknownEither(
//  schema, 
//  { errors: "all" }
// );
decodeAll(data)

(Commented code is not benchmarked)

3.19.177.1MNoneAll errors44 μs
59.49x
stat_minus_1
joi
Code snippet
schema.validate(data, { abortEarly: false })
18.0.216MNoneAll errors59 μs
79.09x
stat_minus_1
zod/mini
Code snippet
schema.safeParse(data)
4.3.685MJITAll errors84 μs
112.57x
stat_minus_1
zod/mini (jitless)
Code snippet
schema.safeParse(data, { jitless: true })
4.3.685MNoneAll errors86 μs
115.38x
stat_minus_1
zod (jitless)
Code snippet
schema.safeParse(data, { jitless: true })
4.3.685MNoneAll errors90 μs
120.46x
stat_minus_1
zod
Code snippet
schema.safeParse(data)
4.3.685MJITAll errors92 μs
123.1x
stat_minus_1
yup
Code snippet
schema.validateSync(data, { abortEarly: true })
Throws on invalid data
This library throws an error when parsing invalid data (and has no non-throwing equivalent), so the benchmark includes a try/catch.
1.7.19.3MNoneAbort early92 μs
124.07x
stat_minus_1
arktype
Code snippet
schema(data)
2.1.29694KJITAll errors98 μs
131.45x
stat_minus_1
rod-js (eager)
Code snippet
schema.safeParse(data, { mode: "eager" })
0.2.138NoneAll errors121 μs
162.62x
stat_minus_1
rod-js (lazy)
Code snippet
schema.safeParse(data, { mode: "lazy" })
0.2.138NoneAll errors128 μs
171.39x
stat_minus_1
@vinejs/vine
Code snippet
vine.tryValidate({ schema, data })
4.3.0136KJITAbort early204 μs
273.84x
stat_minus_2
@vinejs/vine
Code snippet
vine.tryValidate({ schema: schema.bail(false), data })
4.3.0136KJITAll errors208 μs
279.53x
stat_minus_2
typebox (compile)
Code snippet
// const compiled = Compile(schema);
compiled.Parse(data);

(Commented code is not benchmarked)

Throws on invalid data
This library throws an error when parsing invalid data (and has no non-throwing equivalent), so the benchmark includes a try/catch.
1.0.81166KJITAll errors282 μs
379.16x
stat_minus_2
typebox
Code snippet
Value.Parse(schema, data)
Throws on invalid data
This library throws an error when parsing invalid data (and has no non-throwing equivalent), so the benchmark includes a try/catch.
1.0.81166KNoneAll errors295 μs
396.66x
stat_minus_2
yup
Code snippet
schema.validateSync(data, { abortEarly: false })
Throws on invalid data
This library throws an error when parsing invalid data (and has no non-throwing equivalent), so the benchmark includes a try/catch.
1.7.19.3MNoneAll errors517 μs
693.71x
stat_minus_3
Created by eskimojo for Open Circle