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
Libraryarrow_upwardVersiondownload/wksortOptimizationsError typeMeansortCompare
yup (strict)
Code snippetCode snippet
schema.validateSync(data, { abortEarly: true, 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/aNoneAbort early58 μs
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.1n/aNoneAbort early86 μs
1.48x
stat_minus_1
valibot (abortPipeEarly only)
Code snippetCode snippet
v.safeParse(schema, data, { abortPipeEarly: true })
1.5.0n/aNoneAbort early11 μs
5.22x
stat_1
valibot
Code snippetCode snippet
v.safeParse(schema, data, { abortEarly: true })
1.5.0n/aNoneAbort early615 ns
93.98x
stat_2
superstruct (schema.validate)
Code snippetCode snippet
schema.validate(data)
2.0.2n/aNoneAbort early7 μs
8.53x
stat_1
superstruct
Code snippetCode snippet
validate(data, schema)
2.0.2n/aNoneAbort early7 μs
8.63x
stat_1
runtypes (inspect)
Code snippetCode snippet
schema.inspect(data)
7.0.5n/aNoneAbort early183 μs
3.17x
stat_minus_1
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.5n/aNoneAbort early204 μs
3.52x
stat_minus_1
joi (no convert)
Code snippetCode snippet
schema.validate(data, { abortEarly: true, convert: false })
18.3.2n/aNoneAbort early4 μs
15.16x
stat_1
joi
Code snippetCode snippet
schema.validate(data, { abortEarly: true })
18.3.2n/aNoneAbort early4 μs
14.62x
stat_1
effect
Code snippetCode snippet
const decode = Schema.decodeUnknownOption(schema);
decode(data, { errors: "first" })

(Setup code is not benchmarked)

4.1.2n/aNoneAbort early882 ns
65.51x
stat_2
@remix-run/data-schema
Code snippetCode snippet
parseSafe(schema, data, { abortEarly: true })
1.0.0n/aNoneAbort early398 ns
145.4x
stat_3
@railway-ts/pipelines
Code snippetCode snippet
validate(data, schema, { abortEarly: true })
0.1.29n/aNoneAbort early672 ns
85.98x
stat_2
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser
Code ligatures