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
    • assignment_turned_in
      TypeScript

  • 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
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/wksortOptimizationsError typeMeanarrow_upwardCompare
@paseri/paseri (safeParse)
Code snippetCode snippet
p.object(shape).safeParse(data)
1.9.7319NoneAll errors4 μs
io-ts
Code snippetCode snippet
schema.decode(data)
2.2.22n/aNoneAll errors5 μs
1.33x
stat_minus_1
@paseri/paseri (parse)
Code snippetCode snippet
p.object(shape).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.7319NoneAll errors8 μs
2.08x
stat_minus_1
valibot
Code snippetCode snippet
v.safeParse(schema, data)
1.5.0n/aNoneAll errors11 μs
2.8x
stat_minus_1
@remix-run/data-schema
Code snippetCode snippet
parseSafe(schema, data)
1.0.0n/aNoneAll errors13 μs
3.26x
stat_minus_1
effect
Code snippetCode snippet
const decode = Schema.decodeUnknownOption(schema);
decode(data, { errors: "all" })

(Setup code is not benchmarked)

4.1.2n/aNoneAll errors15 μs
3.8x
stat_minus_1
zod/mini (jitless)
Code snippetCode snippet
schema.safeParse(data, { jitless: true })
4.6.7n/aNoneAll errors21 μs
5.33x
stat_minus_1
@railway-ts/pipelines
Code snippetCode snippet
validate(data, schema)
0.1.29n/aNoneAll errors22 μs
5.43x
stat_minus_1
zod (jitless)
Code snippetCode snippet
schema.safeParse(data, { jitless: true })
4.6.7n/aNoneAll errors22 μs
5.44x
stat_minus_1
zod/v3
Code snippetCode snippet
schema.safeParse(data)
4.6.7n/aNoneAll errors33 μs
8.25x
stat_minus_1
decoders
Code snippetCode snippet
schema.decode(data)
2.13.0n/aNoneAll errors44 μs
10.9x
stat_minus_1
joi (no convert)
Code snippetCode snippet
schema.validate(data, { abortEarly: false, convert: false })
18.3.2n/aNoneAll errors57 μs
14.16x
stat_minus_1
joi
Code snippetCode snippet
schema.validate(data, { abortEarly: false })
18.3.2n/aNoneAll errors60 μs
15.13x
stat_minus_1
superstruct (schema.validate)
Code snippetCode snippet
const [error] = schema.validate(data);
for (const failure of error.failures()) {
  // ...
}
2.0.2n/aNoneAll errors73 μs
18.22x
stat_minus_1
superstruct
Code snippetCode snippet
const [error] = validate(data, schema);
for (const failure of error.failures()) {
  // ...
}
2.0.2n/aNoneAll errors73 μs
18.31x
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.0n/aNoneAll errors136 μs
34.17x
stat_minus_2
@sapphire/shapeshift (run)
Code snippetCode snippet
schema.run(data)
5.0.0n/aNoneAll errors138 μs
34.56x
stat_minus_2
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.1n/aNoneAll errors364 μs
91.12x
stat_minus_3
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.1n/aNoneAll errors399 μs
99.92x
stat_minus_3
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser
Code ligatures