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

  • 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 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
  • errorInvalid
  • check_circleValid
Optimizations
  • flash_offNone
  • codeJIT
  • buildPrecompiled
Abort early
  • errorAll errors
  • warningAbort early
LibrarysortVersiondownload/wksortOptimizationsError typeMeanarrow_upwardCompare
@railway-ts/pipelines
Code snippetCode snippet
validate(data, schema, { abortEarly: true })
0.1.29123NoneAbort early649 ns
valibot
Code snippetCode snippet
v.safeParse(schema, data, { abortEarly: true })
1.4.214.88MNoneAbort early743 ns
1.15x
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.10124.3MNoneAbort early1 μs
1.98x
stat_minus_1
joi
Code snippetCode snippet
schema.validate(data, { abortEarly: true })
18.2.320.46MNoneAbort early4 μs
6.08x
stat_minus_1
effect
Code snippetCode snippet
// const decodeFirst = Schema.decodeUnknownEither(
//  schema, 
//  { errors: "first" }
// );
decodeFirst(data)

(Commented code is not benchmarked)

3.22.024.3MNoneAbort early10 μs
15.95x
stat_minus_1
superstruct
Code snippetCode snippet
validate(data, schema)
2.0.25.02MNoneAbort early11 μs
16.92x
stat_minus_1
superstruct (schema.validate)
Code snippetCode snippet
schema.validate(data)
2.0.25.02MNoneAbort early11 μs
17.4x
stat_minus_1
valibot (abortPipeEarly only)
Code snippetCode snippet
v.safeParse(schema, data, { abortPipeEarly: true })
1.4.214.88MNoneAbort early30 μs
45.99x
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.110.52MNoneAbort early101 μs
155.19x
stat_minus_2
runtypes
Code snippetCode snippet
schema.inspect(data)
7.0.5190.07KNoneAbort early183 μs
281.64x
stat_minus_3
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.5190.07KNoneAbort early199 μs
306.82x
stat_minus_3
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser
Code ligatures