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
@railway-ts/pipelines
Code snippetCode snippet
validate(data, schema, { abortEarly: true })
0.1.29n/aNoneAbort early16 μs
@remix-run/data-schema
Code snippetCode snippet
parseSafe(schema, data, { abortEarly: true })
1.0.0n/aNoneAbort early7 μs
2.37x
stat_1
effect
Code snippetCode snippet
const decode = Schema.decodeUnknownOption(schema);
decode(data, { errors: "first" })

(Setup code is not benchmarked)

4.1.2n/aNoneAbort early9 μs
1.84x
stat_1
joi
Code snippetCode snippet
schema.validate(data, { abortEarly: true })
18.3.2n/aNoneAbort early38 μs
2.38x
stat_minus_1
joi (no convert)
Code snippetCode snippet
schema.validate(data, { abortEarly: true, convert: false })
18.3.2n/aNoneAbort early35 μs
2.18x
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 early75 μs
4.72x
stat_minus_2
runtypes (inspect)
Code snippetCode snippet
schema.inspect(data)
7.0.5n/aNoneAbort early73 μs
4.56x
stat_minus_2
superstruct
Code snippetCode snippet
validate(data, schema)
Returns the same objectReturns the same object
This library returned the same object when parsing, instead of creating a new object.
2.0.2n/aNoneAbort early53 μs
3.29x
stat_minus_2
superstruct (schema.validate)
Code snippetCode snippet
schema.validate(data)
Returns the same objectReturns the same object
This library returned the same object when parsing, instead of creating a new object.
2.0.2n/aNoneAbort early52 μs
3.26x
stat_minus_2
valibot
Code snippetCode snippet
v.safeParse(schema, data, { abortEarly: true })
1.5.0n/aNoneAbort early7 μs
2.24x
stat_1
valibot (abortPipeEarly only)
Code snippetCode snippet
v.safeParse(schema, data, { abortPipeEarly: true })
1.5.0n/aNoneAbort early7 μs
2.23x
stat_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.
Returns the same objectReturns the same object
This library returned the same object when parsing, instead of creating a new object.
1.7.1n/aNoneAbort early139 μs
8.71x
stat_minus_3
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.
Returns the same objectReturns the same object
This library returned the same object when parsing, instead of creating a new object.
1.7.1n/aNoneAbort early114 μs
7.15x
stat_minus_3
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser
Code ligatures