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
Code styleCode style
Normal styleNormal style
System themeSystem theme
Light themeLight theme
Dark themeDark theme
Expand sidebarExpand sidebar
Benchmarks/CodecCodec
Code styleCode style
Normal styleNormal style
System themeSystem theme
Light themeLight theme
Dark themeDark theme
github
GitHubGitHub
DiscordDiscord

Some schema libraries support two way conversion of data, often referred to as "encoding" and "decoding".

We benchmark the time taken to encode and decode a Date to and from a string (usually an ISO 8601 string, but we don't enforce this).

Copy to clipboardCopy to clipboard
import * as z from "zod"; const dateFromString = z.codec(z.iso.datetime(), z.date(), { encode: (date) => date.toISOString(), decode: (str) => new Date(str), }); dateFromString.encode(new Date(0)); // "1970-01-01T00:00:00.000Z" dateFromString.decode("1970-01-01T00:00:00.000Z"); // Date
format_quoteInvalid data

We don't benchmark codecs with invalid data, as many libraries require the input to be correctly typed before passing it to the codec.

Optimizations
flash_offNonecodeJITbuildPrecompiled
LibrarysortVersionDownloads (/wk)sortOptimizationsEncodesortDecodearrow_upward
typebox
Accepts unknown valuesAccepts unknown values
This codec allows unknown input, requiring extra validation.
1.1.20243.01KJIT
Code snippetCode snippet
// const DateFromString = Type.Codec(...).Decode(...).Encode(...);
Value.Encode(DateFromString, data)

(Commented code is not benchmarked)

5 μs
Code snippetCode snippet
// const DateFromString = Type.Codec(...).Decode(...).Encode(...);
Value.Decode(DateFromString, data)

(Commented code is not benchmarked)

4 μs
effect (unknown)
Accepts unknown valuesAccepts unknown values
This codec allows unknown input, requiring extra validation.
3.21.08.51MNone
Code snippetCode snippet
Schema.encodeUnknownSync(Schema.Date)(data)
1 μs
Code snippetCode snippet
Schema.decodeUnknownSync(Schema.Date)(data)
865 ns
effect3.21.08.51MNone
Code snippetCode snippet
Schema.encodeSync(Schema.Date)(data)
1 μs
Code snippetCode snippet
Schema.decodeSync(Schema.Date)(data)
863 ns
effect@beta (unknown)
Accepts unknown valuesAccepts unknown values
This codec allows unknown input, requiring extra validation.
4.0.0-beta.438.51MNone
Code snippetCode snippet
// const DateFromString = Schema.Date.pipe(...);
Schema.encodeUnknownSync(DateFromString)(data)

(Commented code is not benchmarked)

1 μs
Code snippetCode snippet
// const DateFromString = Schema.Date.pipe(...);
Schema.decodeUnknownSync(DateFromString)(data)

(Commented code is not benchmarked)

706 ns
effect@beta4.0.0-beta.438.51MNone
Code snippetCode snippet
// const DateFromString = Schema.Date.pipe(...);
Schema.encodeSync(DateFromString)(data)

(Commented code is not benchmarked)

1 μs
Code snippetCode snippet
// const DateFromString = Schema.Date.pipe(...);
Schema.decodeSync(DateFromString)(data)

(Commented code is not benchmarked)

705 ns
zod/mini4.3.6129.93MJIT
Code snippetCode snippet
z.encode(codec, data)
987 ns
Code snippetCode snippet
z.decode(codec, data)
577 ns
zod4.3.6129.93MJIT
Code snippetCode snippet
z.codec(...).encode(data)
974 ns
Code snippetCode snippet
z.codec(...).decode(data)
570 ns
io-ts2.2.222.65MNone
Code snippetCode snippet
// const DateFromString = new t.Type<Date, string, string>(...)
DateFromString.encode(data)

(Commented code is not benchmarked)

552 ns
Code snippetCode snippet
// const DateFromString = new t.Type<Date, string, string>(...)
DateFromString.decode(data)

(Commented code is not benchmarked)

300 ns
Created by eskimojo for Open Circle