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

    • 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
Libraryarrow_upwardVersionDownloads (/wk)sortOptimizationsError typeMeansortCompare
@railway-ts/pipelines
Code snippetCode snippet
validate(data, schema, { abortEarly: true })
0.1.29143NoneAbort early634 ns
@railway-ts/pipelines
Code snippetCode snippet
validate(data, schema)
0.1.29143NoneAll errors29 μs
45.24x
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.
4.0.0846.87KNoneAll errors268 μs
422.53x
stat_minus_2
@sapphire/shapeshift (run)
Code snippetCode snippet
schema.run(data)
4.0.0846.87KNoneAll errors262 μs
413.15x
stat_minus_2
decoders
Code snippetCode snippet
schema.decode(data)
2.9.358.56KNoneAll errors65 μs
103.26x
stat_minus_1
effect
Code snippetCode snippet
// const decodeFirst = Schema.decodeUnknownEither(
//  schema, 
//  { errors: "first" }
// );
decodeFirst(data)

(Commented code is not benchmarked)

3.21.213.85MNoneAbort early10 μs
15.08x
stat_minus_1
effect
Code snippetCode snippet
// const decodeAll = Schema.decodeUnknownEither(
//  schema, 
//  { errors: "all" }
// );
decodeAll(data)

(Commented code is not benchmarked)

3.21.213.85MNoneAll errors30 μs
47.69x
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.6513.85MNoneAbort early1 μs
1.9x
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.6513.85MNoneAll errors20 μs
32.06x
stat_minus_1
io-ts
Code snippetCode snippet
schema.decode(data)
2.2.223.37MNoneAll errors6 μs
9.43x
stat_minus_1
joi
Code snippetCode snippet
schema.validate(data, { abortEarly: true })
18.2.120.07MNoneAbort early4 μs
6.36x
stat_minus_1
joi
Code snippetCode snippet
schema.validate(data, { abortEarly: false })
18.2.120.07MNoneAll errors55 μs
86.5x
stat_minus_1
runtypes
Code snippetCode snippet
schema.inspect(data)
7.0.4310.48KNoneAbort early170 μs
268.46x
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.4310.48KNoneAbort early182 μs
286.51x
stat_minus_2
superstruct
Code snippetCode snippet
validate(data, schema)
2.0.24.68MNoneAbort early10 μs
15.43x
stat_minus_1
superstruct
Code snippetCode snippet
const [error] = validate(data, schema);
for (const failure of error.failures()) {
  // ...
}
2.0.24.68MNoneAll errors74 μs
115.98x
stat_minus_1
superstruct
Code snippetCode snippet
const [error] = schema.validate(data);
for (const failure of error.failures()) {
  // ...
}
2.0.24.68MNoneAll errors74 μs
116.47x
stat_minus_1
superstruct (schema.validate)
Code snippetCode snippet
schema.validate(data)
2.0.24.68MNoneAbort early10 μs
15.83x
stat_minus_1
valibot
Code snippetCode snippet
v.safeParse(schema, data, { abortEarly: true })
1.4.010.19MNoneAbort early715 ns
1.13x
stat_minus_1
valibot
Code snippetCode snippet
v.safeParse(schema, data)
1.4.010.19MNoneAll errors27 μs
42.52x
stat_minus_1
valibot (abortPipeEarly only)
Code snippetCode snippet
v.safeParse(schema, data, { abortPipeEarly: true })
1.4.010.19MNoneAbort early27 μs
42.08x
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.07MNoneAbort early83 μs
130.48x
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.111.07MNoneAll errors484 μs
763.28x
stat_minus_3
zod (jitless)
Code snippetCode snippet
schema.safeParse(data, { jitless: true })
4.4.3165.11MNoneAll errors69 μs
108.12x
stat_minus_1
zod/mini (jitless)
Code snippetCode snippet
schema.safeParse(data, { jitless: true })
4.4.3165.11MNoneAll errors58 μs
91x
stat_minus_1
zod/v3
Code snippetCode snippet
schema.safeParse(data)
4.4.3165.11MNoneAll errors36 μs
56.78x
stat_minus_1
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser