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

  • JSON Schema

    • data_object
      Schema to JSON
    • code
      JSON to Schema
    • verified
      Compliance

    • deployed_code
      Libraries

    • 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 typed value, instead of a boolean.

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
  • errorInvalid
  • check_circleValid
Optimizations
  • flash_offNone
  • codeJIT
  • buildPrecompiled
Abort early
  • errorAll errors
  • warningAbort early
Libraryarrow_upwardVersiondownload/wksortOptimizationsError typeMeansortCompare
@paseri/compiler (parse)
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.
0.7.7155PrecompiledAll errors9 μs
@paseri/compiler (safeParse)
Code snippetCode snippet
schema.safeParse(data)
0.7.7155PrecompiledAll errors1 μs
6.06x
stat_1
@paseri/paseri (parse)
Code snippetCode snippet
p.object(...).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.
1.9.7170NoneAll errors11 μs
1.26x
stat_minus_1
@paseri/paseri (safeParse)
Code snippetCode snippet
p.object(...).safeParse(data)
1.9.7170NoneAll errors4 μs
2.2x
stat_1
@railway-ts/pipelines
Code snippetCode snippet
validate(data, schema, { abortEarly: true })
0.1.29n/aNoneAbort early668 ns
13.28x
stat_1
@railway-ts/pipelines
Code snippetCode snippet
validate(data, schema)
0.1.29n/aNoneAll errors32 μs
3.55x
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.
5.0.0n/aNoneAll errors326 μs
36.72x
stat_minus_2
@sapphire/shapeshift (run)
Code snippetCode snippet
schema.run(data)
5.0.0n/aNoneAll errors323 μs
36.41x
stat_minus_2
arktype
Code snippetCode snippet
schema(data)
2.2.3n/aJITAll errors97 μs
10.92x
stat_minus_1
ata-validator
Code snippetCode snippet
schema.validate(data)
1.7.1n/aJITAll errors695 ns
12.76x
stat_1
decoders
Code snippetCode snippet
schema.decode(data)
2.9.3n/aNoneAll errors66 μs
7.49x
stat_minus_1
effect
Code snippetCode snippet
// const decodeFirst = Schema.decodeUnknownEither(
//  schema, 
//  { errors: "first" }
// );
decodeFirst(data)

(Commented code is not benchmarked)

3.22.0n/aNoneAbort early11 μs
1.19x
stat_minus_1
effect
Code snippetCode snippet
// const decodeAll = Schema.decodeUnknownEither(
//  schema, 
//  { errors: "all" }
// );
decodeAll(data)

(Commented code is not benchmarked)

3.22.0n/aNoneAll errors30 μs
3.41x
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.101n/aNoneAbort early1 μs
7.09x
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.101n/aNoneAll errors21 μs
2.36x
stat_minus_1
io-ts
Code snippetCode snippet
schema.decode(data)
2.2.22n/aNoneAll errors5 μs
1.75x
stat_1
joi
Code snippetCode snippet
schema.validate(data, { abortEarly: true })
18.2.5n/aNoneAbort early4 μs
2.33x
stat_1
joi
Code snippetCode snippet
schema.validate(data, { abortEarly: false })
18.2.5n/aNoneAll errors60 μs
6.73x
stat_minus_1
joi (no convert)
Code snippetCode snippet
schema.validate(data, { abortEarly: true, convert: false })
18.2.5n/aNoneAbort early4 μs
2.39x
stat_1
joi (no convert)
Code snippetCode snippet
schema.validate(data, { abortEarly: false, convert: false })
18.2.5n/aNoneAll errors56 μs
6.29x
stat_minus_1
runtypes
Code snippetCode snippet
schema.inspect(data)
7.0.5n/aNoneAbort early178 μs
20.11x
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.5n/aNoneAbort early196 μs
22.1x
stat_minus_1
superstruct
Code snippetCode snippet
validate(data, schema)
2.0.2n/aNoneAbort early11 μs
1.23x
stat_minus_1
superstruct
Code snippetCode snippet
const [error] = validate(data, schema);
for (const failure of error.failures()) {
  // ...
}
2.0.2n/aNoneAll errors76 μs
8.58x
stat_minus_1
superstruct
Code snippetCode snippet
const [error] = schema.validate(data);
for (const failure of error.failures()) {
  // ...
}
2.0.2n/aNoneAll errors77 μs
8.73x
stat_minus_1
superstruct (schema.validate)
Code snippetCode snippet
schema.validate(data)
2.0.2n/aNoneAbort early11 μs
1.26x
stat_minus_1
sury
Code snippetCode snippet
// const parser = S.parser(S.schema(...));
parser(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-rc.2n/aJITAll errors9 μs
1.01x
stat_1
sury (safe)
Code snippetCode snippet
S.safe(() => parser(data))
11.0.0-rc.2n/aJITAll errors9 μs
1.01x
stat_minus_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.3.18n/aJITAll errors100 μs
11.28x
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.3.18n/aJITAll errors93 μs
10.48x
stat_minus_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.3.18n/aJITAll errors84 μs
9.42x
stat_minus_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.3.18n/aJITAll errors88 μs
9.93x
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.3.18n/aJITAll errors95 μs
10.72x
stat_minus_1
typia (createValidate)
Code snippetCode snippet
// const validate = typia.createValidate<TypiaSchema>();
validate(data);

(Commented code is not benchmarked)

14.0.2n/aPrecompiledAll errors17 μs
1.94x
stat_minus_1
typia (validate)
Code snippetCode snippet
typia.validate<TypiaSchema>(data)
14.0.2n/aPrecompiledAll errors18 μs
2.06x
stat_minus_1
valibot
Code snippetCode snippet
v.safeParse(schema, data, { abortEarly: true })
1.4.2n/aNoneAbort early697 ns
12.73x
stat_1
valibot
Code snippetCode snippet
v.safeParse(schema, data)
1.4.2n/aNoneAll errors31 μs
3.48x
stat_minus_1
valibot (abortPipeEarly only)
Code snippetCode snippet
v.safeParse(schema, data, { abortPipeEarly: true })
1.4.2n/aNoneAbort early30 μs
3.43x
stat_minus_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.1n/aNoneAbort early99 μs
11.13x
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.1n/aNoneAll errors634 μs
71.4x
stat_minus_3
yup (strict)
Code snippetCode snippet
schema.validateSync(data, { abortEarly: true, strict: 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.1n/aNoneAbort early69 μs
7.83x
stat_minus_1
yup (strict)
Code snippetCode snippet
schema.validateSync(data, { abortEarly: false, strict: 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.1n/aNoneAll errors600 μs
67.63x
stat_minus_3
zod
Code snippetCode snippet
schema.safeParse(data)
4.4.3n/aJITAll errors76 μs
8.55x
stat_minus_1
zod (jitless)
Code snippetCode snippet
schema.safeParse(data, { jitless: true })
4.4.3n/aNoneAll errors82 μs
9.2x
stat_minus_1
zod-compiler
Code snippetCode snippet
schema.safeParse(data)
1.28.0n/aPrecompiledAll errors16 μs
1.84x
stat_minus_1
zod-compiler (bag)
Code snippetCode snippet
bagSchema.safeParse(data)
1.28.0n/aPrecompiledAll errors17 μs
1.88x
stat_minus_1
zod-compiler (compact)
Code snippetCode snippet
compactSchema.safeParse(data)
1.28.0n/aPrecompiledAll errors12 μs
1.39x
stat_minus_1
zod/mini
Code snippetCode snippet
schema.safeParse(data)
4.4.3n/aJITAll errors66 μs
7.44x
stat_minus_1
zod/mini (jitless)
Code snippetCode snippet
schema.safeParse(data, { jitless: true })
4.4.3n/aNoneAll errors67 μs
7.5x
stat_minus_1
zod/v3
Code snippetCode snippet
schema.safeParse(data)
4.4.3n/aNoneAll errors41 μs
4.64x
stat_minus_1
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser
Code ligatures