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.2924NoneAbort early650 ns
valibot
Code snippetCode snippet
v.safeParse(schema, data, { abortEarly: true })
1.4.213.57MNoneAbort early794 ns
1.22x
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.9316.97MNoneAbort early1 μs
2.04x
stat_minus_1
joi
Code snippetCode snippet
schema.validate(data, { abortEarly: true })
18.2.316.86MNoneAbort early4 μs
6.04x
stat_minus_1
io-ts
Code snippetCode snippet
schema.decode(data)
2.2.222.34MNoneAll errors6 μs
9.11x
stat_minus_1
typia (createValidate)
Code snippetCode snippet
// const validate = typia.createValidate<TypiaSchema>();
validate(data);

(Commented code is not benchmarked)

12.1.1298.11KPrecompiledAll errors7 μs
10.11x
stat_minus_1
typia (validate)
Code snippetCode snippet
typia.validate<TypiaSchema>(data)
12.1.1298.11KPrecompiledAll errors7 μs
10.64x
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.9207.16KJITAll errors7 μs
11.29x
stat_minus_1
sury (safe)
Code snippetCode snippet
S.safe(() => parser(data))
11.0.0-alpha.9207.16KJITAll errors8 μs
11.64x
stat_minus_1
effect
Code snippetCode snippet
// const decodeFirst = Schema.decodeUnknownEither(
//  schema, 
//  { errors: "first" }
// );
decodeFirst(data)

(Commented code is not benchmarked)

3.21.416.97MNoneAbort early10 μs
14.71x
stat_minus_1
superstruct
Code snippetCode snippet
validate(data, schema)
2.0.25.1MNoneAbort early10 μs
15.47x
stat_minus_1
superstruct (schema.validate)
Code snippetCode snippet
schema.validate(data)
2.0.25.1MNoneAbort early10 μs
16.07x
stat_minus_1
valibot
Code snippetCode snippet
v.safeParse(schema, data)
1.4.213.57MNoneAll errors29 μs
45.3x
stat_minus_1
valibot (abortPipeEarly only)
Code snippetCode snippet
v.safeParse(schema, data, { abortPipeEarly: true })
1.4.213.57MNoneAbort early30 μs
45.68x
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.9316.97MNoneAll errors30 μs
46.73x
stat_minus_1
@railway-ts/pipelines
Code snippetCode snippet
validate(data, schema)
0.1.2924NoneAll errors30 μs
46.78x
stat_minus_1
effect
Code snippetCode snippet
// const decodeAll = Schema.decodeUnknownEither(
//  schema, 
//  { errors: "all" }
// );
decodeAll(data)

(Commented code is not benchmarked)

3.21.416.97MNoneAll errors32 μs
49.27x
stat_minus_1
ata-validator
Code snippetCode snippet
schema.validate(data)
0.21.0443JITAll errors34 μs
51.52x
stat_minus_1
zod/v3
Code snippetCode snippet
schema.safeParse(data)
4.4.3208.07MNoneAll errors40 μs
61.43x
stat_minus_1
joi
Code snippetCode snippet
schema.validate(data, { abortEarly: false })
18.2.316.86MNoneAll errors62 μs
95.75x
stat_minus_1
zod/mini (jitless)
Code snippetCode snippet
schema.safeParse(data, { jitless: true })
4.4.3208.07MNoneAll errors66 μs
100.73x
stat_minus_1
decoders
Code snippetCode snippet
schema.decode(data)
2.9.353.18KNoneAll errors66 μs
102.17x
stat_minus_1
zod/mini
Code snippetCode snippet
schema.safeParse(data)
4.4.3208.07MJITAll errors67 μs
102.3x
stat_minus_1
zod
Code snippetCode snippet
schema.safeParse(data)
4.4.3208.07MJITAll errors76 μs
117.13x
stat_minus_1
superstruct
Code snippetCode snippet
const [error] = validate(data, schema);
for (const failure of error.failures()) {
  // ...
}
2.0.25.1MNoneAll errors80 μs
122.49x
stat_minus_1
superstruct
Code snippetCode snippet
const [error] = schema.validate(data);
for (const failure of error.failures()) {
  // ...
}
2.0.25.1MNoneAll errors80 μs
123.41x
stat_minus_1
zod (jitless)
Code snippetCode snippet
schema.safeParse(data, { jitless: true })
4.4.3208.07MNoneAll errors82 μs
125.58x
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.33.4MJITAll errors82 μs
126.82x
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.33.4MJITAll errors87 μs
133.93x
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.33.4MJITAll errors92 μs
141.16x
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.33.4MJITAll errors93 μs
142.34x
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.19.42MNoneAbort early96 μs
148.37x
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.33.4MJITAll errors98 μs
151.18x
stat_minus_1
arktype
Code snippetCode snippet
schema(data)
2.2.21.15MJITAll errors99 μs
152.34x
stat_minus_1
runtypes
Code snippetCode snippet
schema.inspect(data)
7.0.4238.13KNoneAbort early191 μs
294.12x
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.4238.13KNoneAbort early207 μs
318.86x
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.0764.24KNoneAll errors274 μs
421.87x
stat_minus_2
@sapphire/shapeshift (run)
Code snippetCode snippet
schema.run(data)
4.0.0764.24KNoneAll errors277 μs
425.47x
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.19.42MNoneAll errors546 μs
838.83x
stat_minus_3
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser