LogoLogo

Schema Benchmarks

    • home
      Home

    • download_2
      Download

    • timer
      Initialization
    • check_circle
      Validation
    • output_circle
      Parsing
    • swap_horiz
      Codec
    • schema
      Standard Schema
    • format_quote
      String

    • error
      Stack

    • article
      Blog
Expand sidebarExpand sidebar
Benchmarks/ParsingParsing
github
GitHubGitHub
DiscordDiscord
PreferencesPreferences

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

Copy to clipboardCopy to clipboard
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
Libraryarrow_upwardVersionDownloads (/wk)sortOptimizationsError typeMeansortCompare
@railway-ts/pipelines
Code snippetCode snippet
validate(data, schema, { abortEarly: true })
0.1.29143NoneAbort early17 μs
@railway-ts/pipelines
Code snippetCode snippet
validate(data, schema)
0.1.29143NoneAll errors18 μs
1.03x
stat_minus_1
@sapphire/shapeshift
Code snippetCode snippet
schema.parse(data)
Throws on invalid dataThrows 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.
4.0.0846.87KNoneAll errors25 μs
1.42x
stat_minus_1
@sapphire/shapeshift (run)
Code snippetCode snippet
schema.run(data)
4.0.0846.87KNoneAll errors25 μs
1.42x
stat_minus_1
arktype
Code snippetCode snippet
schema(data)
2.2.0896.39KJITAll errors6 μs
2.82x
stat_1
ata-validator
Code snippetCode snippet
schema.validate(data)
0.13.2750JITAll errors177 ns
98.37x
stat_3
decoders
Code snippetCode snippet
schema.decode(data)
2.9.358.56KNoneAll errors16 μs
1.1x
stat_1
effect
Code snippetCode snippet
// const decodeFirst = Schema.decodeUnknownEither(
//  schema, 
//  { errors: "first" }
// );
decodeFirst(data)

(Commented code is not benchmarked)

3.21.213.85MNoneAbort early19 μs
1.08x
stat_minus_1
effect
Code snippetCode snippet
// const decodeAll = Schema.decodeUnknownEither(
//  schema, 
//  { errors: "all" }
// );
decodeAll(data)

(Commented code is not benchmarked)

3.21.213.85MNoneAll errors20 μs
1.16x
stat_minus_1
effect@beta
Code snippetCode snippet
// const decode = Schema.decodeUnknownOption(schema);
decode(data, { errors: "first" })

(Commented code is not benchmarked)

4.0.0-beta.6513.85MNoneAbort early17 μs
1.04x
stat_1
effect@beta
Code snippetCode snippet
// const decode = Schema.decodeUnknownOption(schema);
decode(data, { errors: "all" })

(Commented code is not benchmarked)

4.0.0-beta.6513.85MNoneAll errors17 μs
1.03x
stat_1
io-ts
Code snippetCode snippet
schema.decode(data)
2.2.223.37MNoneAll errors6 μs
2.84x
stat_1
joi
Code snippetCode snippet
schema.validate(data, { abortEarly: true })
18.2.120.07MNoneAbort early38 μs
2.19x
stat_minus_1
joi
Code snippetCode snippet
schema.validate(data, { abortEarly: false })
18.2.120.07MNoneAll errors38 μs
2.2x
stat_minus_1
runtypes
Code snippetCode snippet
schema.inspect(data)
7.0.4310.48KNoneAbort early68 μs
3.9x
stat_minus_1
runtypes
Code snippetCode snippet
schema.parse(data)
Throws on invalid dataThrows 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.
7.0.4310.48KNoneAbort early68 μs
3.91x
stat_minus_1
superstruct
Code snippetCode snippet
const [error] = schema.validate(data);
for (const failure of error.failures()) {
  // ...
}
2.0.24.68MNoneAll errors52 μs
2.99x
stat_minus_1
superstruct
Code snippetCode snippet
validate(data, schema)
2.0.24.68MNoneAbort early52 μs
3x
stat_minus_1
superstruct
Code snippetCode snippet
const [error] = validate(data, schema);
for (const failure of error.failures()) {
  // ...
}
2.0.24.68MNoneAll errors52 μs
3x
stat_minus_1
superstruct (schema.validate)
Code snippetCode snippet
schema.validate(data)
2.0.24.68MNoneAbort early52 μs
2.99x
stat_minus_1
sury
Code snippetCode snippet
S.parseOrThrow(data, schema)
Throws on invalid dataThrows 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.4194.21KJITAll errors2 μs
7.53x
stat_1
sury (compile + safe)
Code snippetCode snippet
// const compile = S.compile(S.schema(...));
S.safe(() => compile(data));

(Commented code is not benchmarked)

11.0.0-alpha.4194.21KJITAll errors2 μs
7.82x
stat_1
sury (compile)
Code snippetCode snippet
// const compile = S.compile(S.schema(...));
compile(data);

(Commented code is not benchmarked)

Throws on invalid dataThrows 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.4194.21KJITAll errors2 μs
7.83x
stat_1
sury (safe)
Code snippetCode snippet
S.safe(() => S.parseOrThrow(data, schema))
11.0.0-alpha.4194.21KJITAll errors2 μs
7.52x
stat_1
typebox
Code snippetCode snippet
Value.Parse(schema, data)
Throws on invalid dataThrows 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.1.381.75MJITAll errors94 μs
5.41x
stat_minus_1
typebox (compile)
Code snippetCode snippet
// const compiled = Compile(schema);
compiled.Parse(data);

(Commented code is not benchmarked)

Throws on invalid dataThrows 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.1.381.75MJITAll errors3 μs
6.02x
stat_1
typebox (schema compile)
Code snippetCode snippet
// const compiledSchema = Schema.Compile(schema);
compiledSchema.Parse(data);

(Commented code is not benchmarked)

Throws on invalid dataThrows 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.1.381.75MJITAll errors3 μs
6.04x
stat_1
typebox (schema)
Code snippetCode snippet
Schema.Parse(schema, data)
Throws on invalid dataThrows 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.1.381.75MJITAll errors80 μs
4.61x
stat_minus_1
typebox (script compile)
Code snippetCode snippet
// const compiledScriptSchema = Schema.Compile(scriptSchema);
compiledScriptSchema.Parse(data);

(Commented code is not benchmarked)

Throws on invalid dataThrows 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.1.381.75MJITAll errors3 μs
5.84x
stat_1
typia (createValidate)
Code snippetCode snippet
// const validate = typia.createValidate<TypiaSchema>();
validate(data);

(Commented code is not benchmarked)

12.1.1259.87KPrecompiledAll errors1 μs
15.82x
stat_1
typia (validate)
Code snippetCode snippet
typia.validate<TypiaSchema>(data)
12.1.1259.87KPrecompiledAll errors1 μs
14.86x
stat_1
valibot
Code snippetCode snippet
v.safeParse(schema, data, { abortEarly: true })
1.4.010.19MNoneAbort early12 μs
1.48x
stat_1
valibot
Code snippetCode snippet
v.safeParse(schema, data)
1.4.010.19MNoneAll errors12 μs
1.4x
stat_1
valibot (abortPipeEarly only)
Code snippetCode snippet
v.safeParse(schema, data, { abortPipeEarly: true })
1.4.010.19MNoneAbort early12 μs
1.49x
stat_1
yup
Code snippetCode snippet
schema.validateSync(data, { abortEarly: true })
Throws on invalid dataThrows 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.111.07MNoneAbort early132 μs
7.56x
stat_minus_1
yup
Code snippetCode snippet
schema.validateSync(data, { abortEarly: false })
Throws on invalid dataThrows 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.111.07MNoneAll errors132 μs
7.58x
stat_minus_1
zod
Code snippetCode snippet
schema.safeParse(data)
4.4.3165.11MJITAll errors10 μs
1.8x
stat_1
zod (jitless)
Code snippetCode snippet
schema.safeParse(data, { jitless: true })
4.4.3165.11MNoneAll errors16 μs
1.11x
stat_1
zod/mini
Code snippetCode snippet
schema.safeParse(data)
4.4.3165.11MJITAll errors15 μs
1.13x
stat_1
zod/mini (jitless)
Code snippetCode snippet
schema.safeParse(data, { jitless: true })
4.4.3165.11MNoneAll errors15 μs
1.13x
stat_1
zod/v3
Code snippetCode snippet
schema.safeParse(data)
4.4.3165.11MNoneAll errors17 μs
1x
stat_1
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser