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
LibrarysortVersiondownload/wksortOptimizationsError typeMeanarrow_upwardCompare
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 errors637 μs
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 errors604 μs
1.05x
stat_1
@sapphire/shapeshift (run)
Code snippetCode snippet
schema.run(data)
5.0.0n/aNoneAll errors324 μs
1.96x
stat_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 errors324 μs
1.97x
stat_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 early195 μs
3.26x
stat_1
runtypes (inspect)
Code snippetCode snippet
schema.inspect(data)
7.0.5n/aNoneAbort early179 μs
3.55x
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.1n/aNoneAbort early102 μs
6.27x
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.3.18n/aJITAll errors101 μs
6.32x
stat_1
arktype
Code snippetCode snippet
schema(data)
2.2.3n/aJITAll errors98 μs
6.5x
stat_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
6.71x
stat_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 errors94 μs
6.8x
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.3.18n/aJITAll errors89 μs
7.2x
stat_1
zod (jitless)
Code snippetCode snippet
schema.safeParse(data, { jitless: true })
4.4.3n/aNoneAll errors86 μs
7.4x
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.3.18n/aJITAll errors84 μs
7.55x
stat_1
zod
Code snippetCode snippet
schema.safeParse(data)
4.4.3n/aJITAll errors81 μs
7.87x
stat_1
superstruct (schema.validate)
Code snippetCode snippet
const [error] = schema.validate(data);
for (const failure of error.failures()) {
  // ...
}
2.0.2n/aNoneAll errors77 μs
8.29x
stat_1
superstruct
Code snippetCode snippet
const [error] = validate(data, schema);
for (const failure of error.failures()) {
  // ...
}
2.0.2n/aNoneAll errors76 μs
8.36x
stat_1
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 early71 μs
8.97x
stat_1
decoders
Code snippetCode snippet
schema.decode(data)
2.9.3n/aNoneAll errors70 μs
9.14x
stat_1
zod/mini
Code snippetCode snippet
schema.safeParse(data)
4.4.3n/aJITAll errors67 μs
9.5x
stat_1
zod/mini (jitless)
Code snippetCode snippet
schema.safeParse(data, { jitless: true })
4.4.3n/aNoneAll errors67 μs
9.55x
stat_1
joi
Code snippetCode snippet
schema.validate(data, { abortEarly: false })
18.2.5n/aNoneAll errors60 μs
10.58x
stat_1
joi (no convert)
Code snippetCode snippet
schema.validate(data, { abortEarly: false, convert: false })
18.2.5n/aNoneAll errors56 μs
11.41x
stat_1
zod/v3
Code snippetCode snippet
schema.safeParse(data)
4.4.3n/aNoneAll errors41 μs
15.61x
stat_1
@railway-ts/pipelines
Code snippetCode snippet
validate(data, schema)
0.1.29n/aNoneAll errors31 μs
20.33x
stat_1
valibot (abortPipeEarly only)
Code snippetCode snippet
v.safeParse(schema, data, { abortPipeEarly: true })
1.4.2n/aNoneAbort early30 μs
20.95x
stat_1
valibot
Code snippetCode snippet
v.safeParse(schema, data)
1.4.2n/aNoneAll errors30 μs
20.99x
stat_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
21.16x
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 errors20 μs
31.24x
stat_1
typia (validate)
Code snippetCode snippet
typia.validate<TypiaSchema>(data)
14.0.2n/aPrecompiledAll errors18 μs
34.7x
stat_1
typia (createValidate)
Code snippetCode snippet
// const validate = typia.createValidate<TypiaSchema>();
validate(data);

(Commented code is not benchmarked)

14.0.2n/aPrecompiledAll errors17 μs
37.61x
stat_1
zod-compiler (bag)
Code snippetCode snippet
bagSchema.safeParse(data)
1.28.0n/aPrecompiledAll errors17 μs
38.46x
stat_1
zod-compiler
Code snippetCode snippet
schema.safeParse(data)
1.28.0n/aPrecompiledAll errors16 μs
39.5x
stat_1
zod-compiler (compact)
Code snippetCode snippet
compactSchema.safeParse(data)
1.28.0n/aPrecompiledAll errors12 μs
52.36x
stat_1
superstruct (schema.validate)
Code snippetCode snippet
schema.validate(data)
2.0.2n/aNoneAbort early11 μs
56.53x
stat_1
superstruct
Code snippetCode snippet
validate(data, schema)
2.0.2n/aNoneAbort early11 μs
56.54x
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.7180NoneAll errors11 μs
57.62x
stat_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
60.55x
stat_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
67.62x
stat_1
sury (safe)
Code snippetCode snippet
S.safe(() => parser(data))
11.0.0-rc.2n/aJITAll errors9 μs
68.87x
stat_1
@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 errors8 μs
76.12x
stat_1
io-ts
Code snippetCode snippet
schema.decode(data)
2.2.22n/aNoneAll errors5 μs
121.83x
stat_1
joi
Code snippetCode snippet
schema.validate(data, { abortEarly: true })
18.2.5n/aNoneAbort early4 μs
161.48x
stat_1
@paseri/paseri (safeParse)
Code snippetCode snippet
p.object(...).safeParse(data)
1.9.7180NoneAll errors4 μs
162.87x
stat_1
joi (no convert)
Code snippetCode snippet
schema.validate(data, { abortEarly: true, convert: false })
18.2.5n/aNoneAbort early4 μs
167.32x
stat_1
@paseri/compiler (safeParse)
Code snippetCode snippet
schema.safeParse(data)
0.7.7155PrecompiledAll errors1 μs
457.1x
stat_2
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
508.76x
stat_2
valibot
Code snippetCode snippet
v.safeParse(schema, data, { abortEarly: true })
1.4.2n/aNoneAbort early689 ns
925.18x
stat_3
@railway-ts/pipelines
Code snippetCode snippet
validate(data, schema, { abortEarly: true })
0.1.29n/aNoneAbort early659 ns
966.55x
stat_3
ata-validator
Code snippetCode snippet
schema.validate(data)
1.7.1n/aJITAll errors639 ns
996.29x
stat_3
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser
Code ligatures