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 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
  • errorInvalid
  • check_circleValid
Optimizations
  • flash_offNone
  • codeJIT
  • buildPrecompiled
Abort early
  • errorAll errors
  • warningAbort early
LibrarysortVersiondownload/wksortOptimizationsError typeMeanarrow_upwardCompare
ata-validator
Code snippetCode snippet
schema.validate(data)
1.6.11.06KJITAll errors773 ns
@paseri/compiler (safeParse)
Code snippetCode snippet
schema.safeParse(data)
0.7.7123PrecompiledAll errors998 ns
1.29x
stat_minus_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.7123PrecompiledAll errors1 μs
1.32x
stat_minus_1
sury (safe)
Code snippetCode snippet
S.safe(() => parser(data))
11.0.0-rc.1240.68KJITAll errors2 μs
2x
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.1240.68KJITAll errors2 μs
2.01x
stat_minus_1
zod-compiler (compact)
Code snippetCode snippet
compactSchema.safeParse(data)
1.27.031.11KPrecompiledAll errors2 μs
2.63x
stat_minus_1
@paseri/paseri (safeParse)
Code snippetCode snippet
p.object(...).safeParse(data)
1.9.7172NoneAll errors3 μs
4.21x
stat_minus_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.7172NoneAll errors3 μs
4.21x
stat_minus_1
zod-compiler
Code snippetCode snippet
schema.safeParse(data)
1.27.031.11KPrecompiledAll errors3 μs
4.43x
stat_minus_1
zod-compiler (bag)
Code snippetCode snippet
bagSchema.safeParse(data)
1.27.031.11KPrecompiledAll errors4 μs
4.67x
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.157.55MJITAll errors4 μs
4.7x
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.157.55MJITAll errors4 μs
4.74x
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.157.55MJITAll errors4 μs
4.79x
stat_minus_1
io-ts
Code snippetCode snippet
schema.decode(data)
2.2.222.26MNoneAll errors5 μs
6.79x
stat_minus_1
typia (createValidate)
Code snippetCode snippet
// const validate = typia.createValidate<TypiaSchema>();
validate(data);

(Commented code is not benchmarked)

14.0.0271.05KPrecompiledAll errors6 μs
8.01x
stat_minus_1
typia (validate)
Code snippetCode snippet
typia.validate<TypiaSchema>(data)
14.0.0271.05KPrecompiledAll errors6 μs
8.41x
stat_minus_1
arktype
Code snippetCode snippet
schema(data)
2.2.31.4MJITAll errors8 μs
10.67x
stat_minus_1
zod
Code snippetCode snippet
schema.safeParse(data)
4.4.3223.55MJITAll errors8 μs
10.83x
stat_minus_1
valibot (abortPipeEarly only)
Code snippetCode snippet
v.safeParse(schema, data, { abortPipeEarly: true })
1.4.214.88MNoneAbort early11 μs
13.98x
stat_minus_1
valibot
Code snippetCode snippet
v.safeParse(schema, data, { abortEarly: true })
1.4.214.88MNoneAbort early11 μs
14x
stat_minus_1
valibot
Code snippetCode snippet
v.safeParse(schema, data)
1.4.214.88MNoneAll errors11 μs
14.56x
stat_minus_1
zod/v3
Code snippetCode snippet
schema.safeParse(data)
4.4.3223.55MNoneAll errors13 μs
17.3x
stat_minus_1
zod/mini
Code snippetCode snippet
schema.safeParse(data)
4.4.3223.55MJITAll errors14 μs
18.35x
stat_minus_1
zod/mini (jitless)
Code snippetCode snippet
schema.safeParse(data, { jitless: true })
4.4.3223.55MNoneAll errors14 μs
18.55x
stat_minus_1
zod (jitless)
Code snippetCode snippet
schema.safeParse(data, { jitless: true })
4.4.3223.55MNoneAll errors15 μs
19.21x
stat_minus_1
decoders
Code snippetCode snippet
schema.decode(data)
2.9.324.27KNoneAll errors16 μs
20.21x
stat_minus_1
effect@beta
Code snippetCode snippet
// const decode = Schema.decodeUnknownOption(schema);
decode(data, { errors: "all" })

(Commented code is not benchmarked)

4.0.0-beta.10124.3MNoneAll errors16 μs
20.83x
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.10124.3MNoneAbort early16 μs
20.97x
stat_minus_1
@railway-ts/pipelines
Code snippetCode snippet
validate(data, schema, { abortEarly: true })
0.1.29123NoneAbort early16 μs
21.01x
stat_minus_1
effect
Code snippetCode snippet
// const decodeFirst = Schema.decodeUnknownEither(
//  schema, 
//  { errors: "first" }
// );
decodeFirst(data)

(Commented code is not benchmarked)

3.22.024.3MNoneAbort early17 μs
21.67x
stat_minus_1
@railway-ts/pipelines
Code snippetCode snippet
validate(data, schema)
0.1.29123NoneAll errors17 μs
21.73x
stat_minus_1
effect
Code snippetCode snippet
// const decodeAll = Schema.decodeUnknownEither(
//  schema, 
//  { errors: "all" }
// );
decodeAll(data)

(Commented code is not benchmarked)

3.22.024.3MNoneAll errors17 μs
22.16x
stat_minus_1
@sapphire/shapeshift (run)
Code snippetCode snippet
schema.run(data)
5.0.01.06MNoneAll errors23 μs
29.49x
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.01.06MNoneAll errors23 μs
29.64x
stat_minus_1
joi
Code snippetCode snippet
schema.validate(data, { abortEarly: false })
18.2.320.46MNoneAll errors39 μs
50.23x
stat_minus_1
joi
Code snippetCode snippet
schema.validate(data, { abortEarly: true })
18.2.320.46MNoneAbort early40 μs
51.94x
stat_minus_1
superstruct
Code snippetCode snippet
const [error] = validate(data, schema);
for (const failure of error.failures()) {
  // ...
}
2.0.25.02MNoneAll errors51 μs
66.49x
stat_minus_2
superstruct
Code snippetCode snippet
validate(data, schema)
2.0.25.02MNoneAbort early52 μs
66.63x
stat_minus_2
superstruct (schema.validate)
Code snippetCode snippet
schema.validate(data)
2.0.25.02MNoneAbort early52 μs
66.84x
stat_minus_2
superstruct
Code snippetCode snippet
const [error] = schema.validate(data);
for (const failure of error.failures()) {
  // ...
}
2.0.25.02MNoneAll errors52 μs
67x
stat_minus_2
runtypes
Code snippetCode snippet
schema.inspect(data)
7.0.5190.07KNoneAbort early71 μs
91.75x
stat_minus_2
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.5190.07KNoneAbort early71 μs
91.82x
stat_minus_2
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.157.55MJITAll errors81 μs
104.83x
stat_minus_2
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.157.55MJITAll errors89 μs
114.47x
stat_minus_2
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.110.52MNoneAbort early139 μs
179.76x
stat_minus_3
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.110.52MNoneAll errors141 μs
182.03x
stat_minus_3
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser
Code ligatures