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

    • 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
errorInvalidcheck_circleValid
Optimizations
flash_offNonecodeJITbuildPrecompiled
Abort early
errorAll errorswarningAbort early
Libraryarrow_upwardVersionDownloads (/wk)sortOptimizationsError typeMeansortCompare
arktype
Code snippetCode snippet
schema(data)
2.2.0896.39KJITAll errors91 μs
ata-validator
Code snippetCode snippet
schema.validate(data)
0.13.2750JITAll errors738 ns
122.61x
stat_3
sury
Code snippetCode snippet
S.parseOrThrow(data, schema)
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.0.0-alpha.4194.21KJITAll errors8 μs
11.53x
stat_1
sury (compile + safe)
Code snippetCode snippet
// const compile = S.compile(S.schema(...));
S.safe(() => compile(data));

(Commented code is not benchmarked)

11.0.0-alpha.4194.21KJITAll errors8 μs
11.92x
stat_1
sury (compile)
Code snippetCode snippet
// const compile = S.compile(S.schema(...));
compile(data);

(Commented 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.0.0-alpha.4194.21KJITAll errors8 μs
11.96x
stat_1
sury (safe)
Code snippetCode snippet
S.safe(() => S.parseOrThrow(data, schema))
11.0.0-alpha.4194.21KJITAll errors8 μs
11.46x
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.1.381.75MJITAll errors94 μs
1.04x
stat_minus_1
typebox (compile)
Code snippetCode snippet
// const compiled = Compile(schema);
compiled.Parse(data);

(Commented 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.1.381.75MJITAll errors87 μs
1.04x
stat_1
typebox (schema compile)
Code snippetCode snippet
// const compiledSchema = Schema.Compile(schema);
compiledSchema.Parse(data);

(Commented 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.1.381.75MJITAll errors80 μs
1.13x
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.1.381.75MJITAll errors85 μs
1.07x
stat_1
typebox (script compile)
Code snippetCode snippet
// const compiledScriptSchema = Schema.Compile(scriptSchema);
compiledScriptSchema.Parse(data);

(Commented 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.1.381.75MJITAll errors90 μs
1.01x
stat_1
zod
Code snippetCode snippet
schema.safeParse(data)
4.4.3165.11MJITAll errors63 μs
1.43x
stat_1
zod/mini
Code snippetCode snippet
schema.safeParse(data)
4.4.3165.11MJITAll errors58 μs
1.56x
stat_1
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser