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
arktype
Code snippetCode snippet
schema(data)
2.2.9n/aJITAll errors101 μs
ata-validator
Code snippetCode snippet
schema.validate(data)
1.63.153.34KJITAll errors59 ns
1_700.36x
stat_3
ata-validator (parse)
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.
1.63.153.34KJITAll errors6 μs
17.72x
stat_1
sury (asResult)
Code snippetCode snippet
const parseAsResult = S.parseAsResult(S.schema(value));
parseAsResult(data);

(Setup code is not benchmarked)

11.1.0409.26KJITAll errors4 μs
23.82x
stat_1
sury (parseOrThrow + compiled)
Code snippetCode snippet
const parse = S.parseOrThrow(S.schema(value));
parse(data);

(Setup code is not benchmarked)

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.
11.1.0409.26KJITAll errors5 μs
21.27x
stat_1
typebox
Code snippetCode snippet
Value.Parse(schema, 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.4.416.33MJITAll errors17 μs
6x
stat_1
typebox (compile)
Code snippetCode snippet
const compiled = Compile(schema);
compiled.Parse(data);

(Setup code is not benchmarked)

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.4.416.33MJITAll errors13 μs
7.7x
stat_1
typebox (schema compile)
Code snippetCode snippet
const compiledSchema = Schema.Compile(schema);
compiledSchema.Parse(data);

(Setup code is not benchmarked)

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.4.416.33MJITAll errors10 μs
10.33x
stat_1
typebox (schema)
Code snippetCode snippet
Schema.Parse(schema, 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.4.416.33MJITAll errors13 μs
7.93x
stat_1
typebox (script compile)
Code snippetCode snippet
const compiledScriptSchema = Schema.Compile(scriptSchema);
compiledScriptSchema.Parse(data);

(Setup code is not benchmarked)

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.4.416.33MJITAll errors9 μs
10.75x
stat_1
zod
Code snippetCode snippet
schema.safeParse(data)
4.6.7n/aJITAll errors13 μs
8.04x
stat_1
zod (compile)
Code snippetCode snippet
compiledSchema.safeParse(data)
4.6.7n/aJITAll errors14 μs
7.35x
stat_1
zod/mini
Code snippetCode snippet
schema.safeParse(data)
4.6.7n/aJITAll errors21 μs
4.78x
stat_1
zod/mini (compile)
Code snippetCode snippet
compiledSchema.safeParse(data)
4.6.7n/aJITAll errors21 μs
4.75x
stat_1
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser
Code ligatures