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

    • 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
errorInvalidcheck_circleValid
Optimizations
flash_offNonecodeJITbuildPrecompiled
Abort early
errorAll errorswarningAbort early
LibrarysortVersionDownloads (/wk)sortOptimizationsError typeMeanarrow_upwardCompare
@railway-ts/pipelines
Code snippetCode snippet
validate(data, schema, { abortEarly: true })
0.1.29105NoneAbort early672 ns
valibot
Code snippetCode snippet
v.safeParse(schema, data, { abortEarly: true })
1.4.112.21MNoneAbort early764 ns
1.14x
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.7818.38MNoneAbort early1 μs
1.62x
stat_minus_1
joi
Code snippetCode snippet
schema.validate(data, { abortEarly: true })
18.2.122.51MNoneAbort early4 μs
6.09x
stat_minus_1
typia (createValidate)
Code snippetCode snippet
// const validate = typia.createValidate<TypiaSchema>();
validate(data);

(Commented code is not benchmarked)

12.1.1321.84KPrecompiledAll errors7 μs
9.86x
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-alpha.7190.79KJITAll errors7 μs
9.89x
stat_minus_1
typia (validate)
Code snippetCode snippet
typia.validate<TypiaSchema>(data)
12.1.1321.84KPrecompiledAll errors7 μs
10.01x
stat_minus_1
io-ts
Code snippetCode snippet
schema.decode(data)
2.2.223.76MNoneAll errors7 μs
10.25x
stat_minus_1
sury (safe)
Code snippetCode snippet
S.safe(() => parser(data))
11.0.0-alpha.7190.79KJITAll errors7 μs
10.62x
stat_minus_1
effect
Code snippetCode snippet
// const decodeFirst = Schema.decodeUnknownEither(
//  schema, 
//  { errors: "first" }
// );
decodeFirst(data)

(Commented code is not benchmarked)

3.21.318.38MNoneAbort early9 μs
13.86x
stat_minus_1
superstruct
Code snippetCode snippet
validate(data, schema)
2.0.25.29MNoneAbort early11 μs
15.98x
stat_minus_1
superstruct (schema.validate)
Code snippetCode snippet
schema.validate(data)
2.0.25.29MNoneAbort early11 μs
16.07x
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.7818.38MNoneAll errors20 μs
30.26x
stat_minus_1
valibot
Code snippetCode snippet
v.safeParse(schema, data)
1.4.112.21MNoneAll errors29 μs
42.6x
stat_minus_1
valibot (abortPipeEarly only)
Code snippetCode snippet
v.safeParse(schema, data, { abortPipeEarly: true })
1.4.112.21MNoneAbort early29 μs
42.71x
stat_minus_1
@railway-ts/pipelines
Code snippetCode snippet
validate(data, schema)
0.1.29105NoneAll errors30 μs
45.3x
stat_minus_1
ata-validator
Code snippetCode snippet
schema.validate(data)
0.21.0499JITAll errors32 μs
47.25x
stat_minus_1
effect
Code snippetCode snippet
// const decodeAll = Schema.decodeUnknownEither(
//  schema, 
//  { errors: "all" }
// );
decodeAll(data)

(Commented code is not benchmarked)

3.21.318.38MNoneAll errors34 μs
49.99x
stat_minus_1
zod/v3
Code snippetCode snippet
schema.safeParse(data)
4.4.3193.66MNoneAll errors39 μs
57.62x
stat_minus_1
joi
Code snippetCode snippet
schema.validate(data, { abortEarly: false })
18.2.122.51MNoneAll errors54 μs
80.43x
stat_minus_1
zod/mini (jitless)
Code snippetCode snippet
schema.safeParse(data, { jitless: true })
4.4.3193.66MNoneAll errors58 μs
86.29x
stat_minus_1
zod/mini
Code snippetCode snippet
schema.safeParse(data)
4.4.3193.66MJITAll errors58 μs
86.97x
stat_minus_1
zod
Code snippetCode snippet
schema.safeParse(data)
4.4.3193.66MJITAll errors68 μs
100.43x
stat_minus_1
zod (jitless)
Code snippetCode snippet
schema.safeParse(data, { jitless: true })
4.4.3193.66MNoneAll errors71 μs
105.89x
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.2.14.68MJITAll errors75 μs
112.05x
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.2.14.68MJITAll errors80 μs
118.45x
stat_minus_1
superstruct
Code snippetCode snippet
const [error] = validate(data, schema);
for (const failure of error.failures()) {
  // ...
}
2.0.25.29MNoneAll errors82 μs
121.88x
stat_minus_1
superstruct
Code snippetCode snippet
const [error] = schema.validate(data);
for (const failure of error.failures()) {
  // ...
}
2.0.25.29MNoneAll errors82 μs
122.5x
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.2.14.68MJITAll errors83 μs
123.11x
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.2.14.68MJITAll errors87 μs
128.86x
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.112.33MNoneAbort early88 μs
130.58x
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.2.14.68MJITAll errors89 μs
132.21x
stat_minus_1
decoders
Code snippetCode snippet
schema.decode(data)
2.9.365.91KNoneAll errors96 μs
142.56x
stat_minus_1
arktype
Code snippetCode snippet
schema(data)
2.2.01.15MJITAll errors105 μs
155.46x
stat_minus_1
runtypes
Code snippetCode snippet
schema.inspect(data)
7.0.4320.04KNoneAbort early192 μs
285.87x
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.4320.04KNoneAbort early206 μs
306.02x
stat_minus_2
@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.0889.36KNoneAll errors265 μs
394.3x
stat_minus_2
@sapphire/shapeshift (run)
Code snippetCode snippet
schema.run(data)
4.0.0889.36KNoneAll errors267 μs
397.71x
stat_minus_2
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.33MNoneAll errors496 μs
736.88x
stat_minus_3
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser