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.29148NoneAbort early480 ns
@remix-run/data-schema
Code snippetCode snippet
parseSafe(schema, data, { abortEarly: true })
1.0.014.55KNoneAbort early270 ns
1.78x
stat_1
effect
Code snippetCode snippet
const decode = Schema.decodeUnknownOption(schema);
decode(data, { errors: "first" })

(Setup code is not benchmarked)

4.0.151.26MNoneAbort early670 ns
1.4x
stat_minus_1
joi
Code snippetCode snippet
schema.validate(data, { abortEarly: true })
18.2.931.1MNoneAbort early3 μs
6.54x
stat_minus_1
joi (no convert)
Code snippetCode snippet
schema.validate(data, { abortEarly: true, convert: false })
18.2.931.1MNoneAbort early3 μs
6.42x
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 early138 μs
286.7x
stat_minus_3
runtypes (inspect)
Code snippetCode snippet
schema.inspect(data)
7.0.5n/aNoneAbort early126 μs
262.59x
stat_minus_3
superstruct
Code snippetCode snippet
validate(data, schema)
2.0.27.87MNoneAbort early5 μs
11.06x
stat_minus_1
superstruct (schema.validate)
Code snippetCode snippet
schema.validate(data)
2.0.27.87MNoneAbort early5 μs
11.12x
stat_minus_1
valibot
Code snippetCode snippet
v.safeParse(schema, data, { abortEarly: true })
1.5.025.54MNoneAbort early412 ns
1.16x
stat_1
valibot (abortPipeEarly only)
Code snippetCode snippet
v.safeParse(schema, data, { abortPipeEarly: true })
1.5.025.54MNoneAbort early8 μs
17.33x
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.1n/aNoneAbort early57 μs
118.24x
stat_minus_2
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 early39 μs
80.84x
stat_minus_1
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser
Code ligatures