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.2947NoneAbort early623 ns
valibot
Code snippetCode snippet
v.safeParse(schema, data, { abortEarly: true })
1.4.111.77MNoneAbort early667 ns
1.07x
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.7819.4MNoneAbort early1 μs
2.13x
stat_minus_1
joi
Code snippetCode snippet
schema.validate(data, { abortEarly: true })
18.2.120.9MNoneAbort early4 μs
6.58x
stat_minus_1
io-ts
Code snippetCode snippet
schema.decode(data)
2.2.223.14MNoneAll errors6 μs
9.68x
stat_minus_1
typia (createValidate)
Code snippetCode snippet
// const validate = typia.createValidate<TypiaSchema>();
validate(data);

(Commented code is not benchmarked)

12.1.1282.55KPrecompiledAll errors6 μs
10.08x
stat_minus_1
typia (validate)
Code snippetCode snippet
typia.validate<TypiaSchema>(data)
12.1.1282.55KPrecompiledAll errors7 μs
10.6x
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.7263.43KJITAll errors7 μs
10.86x
stat_minus_1
sury (safe)
Code snippetCode snippet
S.safe(() => parser(data))
11.0.0-alpha.7263.43KJITAll errors8 μs
12.06x
stat_minus_1
effect
Code snippetCode snippet
// const decodeFirst = Schema.decodeUnknownEither(
//  schema, 
//  { errors: "first" }
// );
decodeFirst(data)

(Commented code is not benchmarked)

3.21.319.4MNoneAbort early9 μs
14.72x
stat_minus_1
superstruct (schema.validate)
Code snippetCode snippet
schema.validate(data)
2.0.25.31MNoneAbort early10 μs
16.12x
stat_minus_1
superstruct
Code snippetCode snippet
validate(data, schema)
2.0.25.31MNoneAbort early10 μs
16.5x
stat_minus_1
valibot (abortPipeEarly only)
Code snippetCode snippet
v.safeParse(schema, data, { abortPipeEarly: true })
1.4.111.77MNoneAbort early27 μs
43.88x
stat_minus_1
valibot
Code snippetCode snippet
v.safeParse(schema, data)
1.4.111.77MNoneAll errors27 μs
44.15x
stat_minus_1
@railway-ts/pipelines
Code snippetCode snippet
validate(data, schema)
0.1.2947NoneAll errors29 μs
47.06x
stat_minus_1
effect
Code snippetCode snippet
// const decodeAll = Schema.decodeUnknownEither(
//  schema, 
//  { errors: "all" }
// );
decodeAll(data)

(Commented code is not benchmarked)

3.21.319.4MNoneAll errors30 μs
48.25x
stat_minus_1
ata-validator
Code snippetCode snippet
schema.validate(data)
0.21.01.11KJITAll errors30 μs
48.94x
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.7819.4MNoneAll errors31 μs
49.17x
stat_minus_1
zod/v3
Code snippetCode snippet
schema.safeParse(data)
4.4.3185.36MNoneAll errors37 μs
60x
stat_minus_1
joi
Code snippetCode snippet
schema.validate(data, { abortEarly: false })
18.2.120.9MNoneAll errors56 μs
89.46x
stat_minus_1
zod/mini (jitless)
Code snippetCode snippet
schema.safeParse(data, { jitless: true })
4.4.3185.36MNoneAll errors57 μs
90.88x
stat_minus_1
zod/mini
Code snippetCode snippet
schema.safeParse(data)
4.4.3185.36MJITAll errors57 μs
91.78x
stat_minus_1
zod
Code snippetCode snippet
schema.safeParse(data)
4.4.3185.36MJITAll errors63 μs
100.71x
stat_minus_1
zod (jitless)
Code snippetCode snippet
schema.safeParse(data, { jitless: true })
4.4.3185.36MNoneAll errors69 μs
110.71x
stat_minus_1
superstruct
Code snippetCode snippet
const [error] = validate(data, schema);
for (const failure of error.failures()) {
  // ...
}
2.0.25.31MNoneAll errors74 μs
118.38x
stat_minus_1
superstruct
Code snippetCode snippet
const [error] = schema.validate(data);
for (const failure of error.failures()) {
  // ...
}
2.0.25.31MNoneAll errors74 μs
119.42x
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.17MJITAll errors80 μs
128.36x
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.111.72MNoneAbort early83 μs
133.84x
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.17MJITAll errors86 μs
137.47x
stat_minus_1
decoders
Code snippetCode snippet
schema.decode(data)
2.9.356.59KNoneAll errors86 μs
138.01x
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.17MJITAll errors87 μs
140.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.17MJITAll errors90 μs
144.72x
stat_minus_1
arktype
Code snippetCode snippet
schema(data)
2.2.01.1MJITAll errors91 μs
145.48x
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.17MJITAll errors94 μs
151.42x
stat_minus_1
runtypes
Code snippetCode snippet
schema.inspect(data)
7.0.4312.8KNoneAbort early172 μs
276.72x
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.4312.8KNoneAbort early182 μs
291.71x
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.0786.16KNoneAll errors262 μs
421.04x
stat_minus_2
@sapphire/shapeshift (run)
Code snippetCode snippet
schema.run(data)
4.0.0786.16KNoneAll errors262 μs
421.53x
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.111.72MNoneAll errors481 μs
773.08x
stat_minus_3
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser