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/wkarrow_upwardOptimizationsError typeMeansortCompare
zod
Code snippetCode snippet
schema.safeParse(data)
4.4.3270.11MJITAll errors81 μs
zod (jitless)
Code snippetCode snippet
schema.safeParse(data, { jitless: true })
4.4.3270.11MNoneAll errors86 μs
1.06x
stat_minus_1
zod/mini
Code snippetCode snippet
schema.safeParse(data)
4.4.3270.11MJITAll errors67 μs
1.21x
stat_1
zod/mini (jitless)
Code snippetCode snippet
schema.safeParse(data, { jitless: true })
4.4.3270.11MNoneAll errors67 μs
1.21x
stat_1
zod/v3
Code snippetCode snippet
schema.safeParse(data)
4.4.3270.11MNoneAll errors41 μs
1.98x
stat_1
effect
Code snippetCode snippet
// const decodeFirst = Schema.decodeUnknownEither(
//  schema, 
//  { errors: "first" }
// );
decodeFirst(data)

(Commented code is not benchmarked)

3.22.031.1MNoneAbort early11 μs
7.69x
stat_1
effect
Code snippetCode snippet
// const decodeAll = Schema.decodeUnknownEither(
//  schema, 
//  { errors: "all" }
// );
decodeAll(data)

(Commented code is not benchmarked)

3.22.031.1MNoneAll errors30 μs
2.69x
stat_1
effect@beta
Code snippetCode snippet
// const decode = Schema.decodeUnknownOption(schema);
decode(data, { errors: "first" })

(Commented code is not benchmarked)

4.0.0-beta.10131.1MNoneAbort early1 μs
64.64x
stat_2
effect@beta
Code snippetCode snippet
// const decode = Schema.decodeUnknownOption(schema);
decode(data, { errors: "all" })

(Commented code is not benchmarked)

4.0.0-beta.10131.1MNoneAll errors20 μs
3.97x
stat_1
joi
Code snippetCode snippet
schema.validate(data, { abortEarly: true })
18.2.525.57MNoneAbort early4 μs
20.52x
stat_1
joi
Code snippetCode snippet
schema.validate(data, { abortEarly: false })
18.2.525.57MNoneAll errors60 μs
1.34x
stat_1
joi (no convert)
Code snippetCode snippet
schema.validate(data, { abortEarly: true, convert: false })
18.2.525.57MNoneAbort early4 μs
21.26x
stat_1
joi (no convert)
Code snippetCode snippet
schema.validate(data, { abortEarly: false, convert: false })
18.2.525.57MNoneAll errors56 μs
1.45x
stat_1
valibot
Code snippetCode snippet
v.safeParse(schema, data, { abortEarly: true })
1.4.217.99MNoneAbort early689 ns
117.55x
stat_3
valibot
Code snippetCode snippet
v.safeParse(schema, data)
1.4.217.99MNoneAll errors30 μs
2.67x
stat_1
valibot (abortPipeEarly only)
Code snippetCode snippet
v.safeParse(schema, data, { abortPipeEarly: true })
1.4.217.99MNoneAbort early30 μs
2.66x
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.112.82MNoneAbort early102 μs
1.25x
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.112.82MNoneAll errors637 μs
7.87x
stat_minus_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.112.82MNoneAbort early71 μs
1.14x
stat_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.112.82MNoneAll errors604 μs
7.47x
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.188.78MJITAll errors101 μs
1.24x
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.188.78MJITAll errors94 μs
1.16x
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.188.78MJITAll errors84 μs
1.04x
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.188.78MJITAll errors89 μs
1.09x
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.188.78MJITAll errors95 μs
1.17x
stat_minus_1
superstruct
Code snippetCode snippet
validate(data, schema)
2.0.26.18MNoneAbort early11 μs
7.18x
stat_1
superstruct
Code snippetCode snippet
const [error] = validate(data, schema);
for (const failure of error.failures()) {
  // ...
}
2.0.26.18MNoneAll errors76 μs
1.06x
stat_1
superstruct (schema.validate)
Code snippetCode snippet
schema.validate(data)
2.0.26.18MNoneAbort early11 μs
7.18x
stat_1
superstruct (schema.validate)
Code snippetCode snippet
const [error] = schema.validate(data);
for (const failure of error.failures()) {
  // ...
}
2.0.26.18MNoneAll errors77 μs
1.05x
stat_1
io-ts
Code snippetCode snippet
schema.decode(data)
2.2.222.76MNoneAll errors5 μs
15.48x
stat_1
arktype
Code snippetCode snippet
schema(data)
2.2.31.74MJITAll errors98 μs
1.21x
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.26MNoneAll errors324 μs
4x
stat_minus_1
@sapphire/shapeshift (run)
Code snippetCode snippet
schema.run(data)
5.0.01.26MNoneAll errors324 μs
4.01x
stat_minus_1
typia (createValidate)
Code snippetCode snippet
// const validate = typia.createValidate<TypiaSchema>();
validate(data);

(Commented code is not benchmarked)

14.0.2334.75KPrecompiledAll errors17 μs
4.78x
stat_1
typia (validate)
Code snippetCode snippet
typia.validate<TypiaSchema>(data)
14.0.2334.75KPrecompiledAll errors18 μs
4.41x
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.2320.42KJITAll errors9 μs
8.59x
stat_1
sury (safe)
Code snippetCode snippet
S.safe(() => parser(data))
11.0.0-rc.2320.42KJITAll errors9 μs
8.75x
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.5230.26KNoneAbort early195 μs
2.41x
stat_minus_1
runtypes (inspect)
Code snippetCode snippet
schema.inspect(data)
7.0.5230.26KNoneAbort early179 μs
2.22x
stat_minus_1
zod-compiler
Code snippetCode snippet
schema.safeParse(data)
1.28.076.26KPrecompiledAll errors16 μs
5.02x
stat_1
zod-compiler (bag)
Code snippetCode snippet
bagSchema.safeParse(data)
1.28.076.26KPrecompiledAll errors17 μs
4.89x
stat_1
zod-compiler (compact)
Code snippetCode snippet
compactSchema.safeParse(data)
1.28.076.26KPrecompiledAll errors12 μs
6.65x
stat_1
decoders
Code snippetCode snippet
schema.decode(data)
2.9.328.56KNoneAll errors70 μs
1.16x
stat_1
ata-validator
Code snippetCode snippet
schema.validate(data)
1.7.12.29KJITAll errors639 ns
126.58x
stat_3
@railway-ts/pipelines
Code snippetCode snippet
validate(data, schema, { abortEarly: true })
0.1.29303NoneAbort early659 ns
122.81x
stat_3
@railway-ts/pipelines
Code snippetCode snippet
validate(data, schema)
0.1.29303NoneAll errors31 μs
2.58x
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.7144NoneAll errors11 μs
7.32x
stat_1
@paseri/paseri (safeParse)
Code snippetCode snippet
p.object(...).safeParse(data)
1.9.7144NoneAll errors4 μs
20.69x
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.7141PrecompiledAll errors8 μs
9.67x
stat_1
@paseri/compiler (safeParse)
Code snippetCode snippet
schema.safeParse(data)
0.7.7141PrecompiledAll errors1 μs
58.08x
stat_2
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser
Code ligatures