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

Comparison of the errors thrown by libraries, including stack trace length.

Copy to clipboardCopy to clipboard
import { personSchema } from "./schemas"; import * as v from "valibot"; try { v.parse(personSchema, data); } catch (e) { console.error(e); }

Where error.stack is available, we measure how many frames it takes to reach the line of user code (as opposed to library code).

ValiError: Invalid length: Expected >=1 but received 0
    at Module.parse (file:///node_modules/.pnpm/valibot@1.2.0_typescript@6.0.0-beta/node_modules/valibot/dist/index.mjs:6748:28)
    at Object.throw (file:///schemas/dist/benchmarks-D-_Y96Ph.js:93:6)
    at file:///bench/src/scripts/stack/log.ts:24:28
LibrarysortVersionDownloads (/wk)sortFrame #arrow_upwardLine countsort
runtypes
Code snippetCode snippet
schema.check(data)
Error outputError output
ValidationError: Expected { id: number; created: Date; title: string; brand: string; description: string; price: number; discount: number | null; quantity: number; tags: string[]; images: { id: number; created: Date; title: string; type: "jpg" | "png"; size: number; url: string; }[]; ratings: { id: number; stars: number; title: string; text: string; images: { id: number; created: Date; title: string; type: "jpg" | "png"; size: number; url: string; }[]; }[]; }, but was incompatible
    at Object.check (file:///node_modules/.pnpm/runtypes@7.0.4/node_modules/runtypes/esm/Runtype.js:119:19)
    at Object.throw (file:///schemas/dist/benchmarks-DutXK7Wh.js:76:6)
    at file:///bench/src/scripts/stack/log.ts:24:28 {
  failure: {
    success: false,
    message: 'Expected { id: number; created: Date; title: string; brand: string; description: string; price: number; discount: number | null; quantity: number; tags: string[]; images: { id: number; created: Date; title: string; type: "jpg" | "png"; size: number; url: string; }[]; ratings: { id: number; stars: number; title: string; text: string; images: { id: number; created: Date; title: string; type: "jpg" | "png"; size: number; url: string; }[]; }[]; }, but was incompatible',
    code: 'CONTENT_INCORRECT',
    expected: Object [Runtype<{ id: number; created: Date; title: string; brand: string; description: string; price: number; discount: number | null; quantity: number; tags: string[]; images: { id: number; created: Date; title: string; type: "jpg" | "png"; size: number; url: string; }[]; ratings: { id: number; stars: number; title: string; text: string; images: { id: number; created: Date; title: string; type: "jpg" | "png"; size: number; url: string; }[]; }[]; }>] {
      tag: 'object',
      fields: [Object],
      isExact: false
    },
    received: {
      id: 252,
      created: 2026-03-27T14:37:26.509Z,
      title: '',
      brand: 'Sunny Backyard',
      description: 'Red apple from Lake Constance',
      price: 0,
      discount: null,
      quantity: 1000,
      tags: [Array],
      images: [Array],
      ratings: [Array]
    },
    details: {
      title: [Object],
      price: [Object],
      quantity: [Object],
      tags: [Object],
      images: [Object],
      ratings: [Object]
    }
  }
}
7.0.4267.22K2
37
typebox
Code snippetCode snippet
Value.Parse(schema, data)
Error outputError output
ParseError: Parse
    at Module.Parse (file:///node_modules/.pnpm/typebox@1.1.6/node_modules/typebox/build/value/parse/parse.mjs:46:11)
    at Object.throw (file:///schemas/dist/benchmarks-Bkz-3neE.js:214:6)
    at file:///bench/src/scripts/stack/log.ts:24:28 {
  [cause]: {
    source: 'Parse',
    errors: [
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object]
    ],
    value: {
      id: 252,
      created: 2026-03-27T14:37:26.990Z,
      title: '',
      brand: 'Sunny Backyard',
      description: 'Red apple from Lake Constance',
      price: 0,
      discount: null,
      quantity: 1000,
      tags: [Array],
      images: [Array],
      ratings: [Array]
    }
  }
}
1.1.6227.74K2
28
valibot
Code snippetCode snippet
v.parse(schema, data)
Error outputError output
ValiError: Invalid length: Expected >=1 but received 0
    at Module.parse (file:///node_modules/.pnpm/valibot@1.3.1_typescript@6.0.2/node_modules/valibot/dist/index.mjs:7142:28)
    at Object.throw (file:///schemas/dist/benchmarks-Bbt_t08e.js:95:6)
    at file:///bench/src/scripts/stack/log.ts:24:28 {
  issues: [
    {
      kind: 'validation',
      type: 'min_length',
      input: '',
      expected: '>=1',
      received: '0',
      message: 'Invalid length: Expected >=1 but received 0',
      requirement: 1,
      path: [Array],
      issues: undefined,
      lang: undefined,
      abortEarly: undefined,
      abortPipeEarly: undefined
    },
    {
      kind: 'validation',
      type: 'min_value',
      input: 0,
      expected: '>=1',
      received: '0',
      message: 'Invalid value: Expected >=1 but received 0',
      requirement: 1,
      path: [Array],
      issues: undefined,
      lang: undefined,
      abortEarly: undefined,
      abortPipeEarly: undefined
    },
    {
      kind: 'validation',
      type: 'max_value',
      input: 1000,
      expected: '<=10',
      received: '1000',
      message: 'Invalid value: Expected <=10 but received 1000',
      requirement: 10,
      path: [Array],
      issues: undefined,
      lang: undefined,
      abortEarly: undefined,
      abortPipeEarly: undefined
    },
    {
      kind: 'schema',
      type: 'string',
      input: null,
      expected: 'string',
      received: 'null',
      message: 'Invalid type: Expected string but received null',
      requirement: undefined,
      path: [Array],
      issues: undefined,
      lang: undefined,
      abortEarly: undefined,
      abortPipeEarly: undefined
    },
    {
      kind: 'schema',
      type: 'string',
      input: undefined,
      expected: 'string',
      received: 'undefined',
      message: 'Invalid type: Expected string but received undefined',
      requirement: undefined,
      path: [Array],
      issues: undefined,
      lang: undefined,
      abortEarly: undefined,
      abortPipeEarly: undefined
    },
    {
      kind: 'schema',
      type: 'object',
      input: undefined,
      expected: '"id"',
      received: 'undefined',
      message: 'Invalid key: Expected "id" but received undefined',
      requirement: undefined,
      path: [Array],
      issues: undefined,
      lang: undefined,
      abortEarly: undefined,
      abortPipeEarly: undefined
    },
    {
      kind: 'schema',
      type: 'date',
      input: null,
      expected: 'Date',
      received: 'null',
      message: 'Invalid type: Expected Date but received null',
      requirement: undefined,
      path: [Array],
      issues: undefined,
      lang: undefined,
      abortEarly: undefined,
      abortPipeEarly: undefined
    },
    {
      kind: 'schema',
      type: 'picklist',
      input: 'mp4',
      expected: '("jpg" | "png")',
      received: '"mp4"',
      message: 'Invalid type: Expected ("jpg" | "png") but received "mp4"',
      requirement: undefined,
      path: [Array],
      issues: undefined,
      lang: undefined,
      abortEarly: undefined,
      abortPipeEarly: undefined
    },
    {
      kind: 'schema',
      type: 'object',
      input: undefined,
      expected: '"url"',
      received: 'undefined',
      message: 'Invalid key: Expected "url" but received undefined',
      requirement: undefined,
      path: [Array],
      issues: undefined,
      lang: undefined,
      abortEarly: undefined,
      abortPipeEarly: undefined
    },
    {
      kind: 'schema',
      type: 'number',
      input: '352',
      expected: 'number',
      received: '"352"',
      message: 'Invalid type: Expected number but received "352"',
      requirement: undefined,
      path: [Array],
      issues: undefined,
      lang: undefined,
      abortEarly: undefined,
      abortPipeEarly: undefined
    },
    {
      kind: 'schema',
      type: 'date',
      input: undefined,
      expected: 'Date',
      received: 'undefined',
      message: 'Invalid type: Expected Date but received undefined',
      requirement: undefined,
      path: [Array],
      issues: undefined,
      lang: undefined,
      abortEarly: undefined,
      abortPipeEarly: undefined
    },
    {
      kind: 'validation',
      type: 'url',
      input: 'INVALID_URL',
      expected: null,
      received: '"INVALID_URL"',
      message: 'Invalid URL: Received "INVALID_URL"',
      requirement: [Function: requirement],
      path: [Array],
      issues: undefined,
      lang: undefined,
      abortEarly: undefined,
      abortPipeEarly: undefined
    },
    {
      kind: 'schema',
      type: 'object',
      input: undefined,
      expected: '"title"',
      received: 'undefined',
      message: 'Invalid key: Expected "title" but received undefined',
      requirement: undefined,
      path: [Array],
      issues: undefined,
      lang: undefined,
      abortEarly: undefined,
      abortPipeEarly: undefined
    },
    {
      kind: 'schema',
      type: 'object',
      input: undefined,
      expected: '"type"',
      received: 'undefined',
      message: 'Invalid key: Expected "type" but received undefined',
      requirement: undefined,
      path: [Array],
      issues: undefined,
      lang: undefined,
      abortEarly: undefined,
      abortPipeEarly: undefined
    },
    {
      kind: 'schema',
      type: 'object',
      input: undefined,
      expected: '"size"',
      received: 'undefined',
      message: 'Invalid key: Expected "size" but received undefined',
      requirement: undefined,
      path: [Array],
      issues: undefined,
      lang: undefined,
      abortEarly: undefined,
      abortPipeEarly: undefined
    }
  ]
}
1.3.17.42M2
218
decoders
Code snippetCode snippet
schema.verify(data)
Error outputError output
Decoding error: 
{
  "id": 252,
  "created": new Date('2026-03-27T14:37:25.134Z'),
  "title": "",
           ^^ Too short, must be at least 1 char
  "brand": "Sunny Backyard",
  "description": "Red apple from Lake Constance",
  "price": 0,
           ^ Too low, must be between 1 and 10000
  "discount": null,
  "quantity": 1000,
              ^^^^ Too high, must be between 1 and 10
  "tags": [
    "fruit",
    null,
    ^^^^ Must be string (at index 1)
    "round",
    undefined,
    "juicy",
    "healthy",
  ],
  "images": [
    {
      "created": null,
                 ^^^^ Must be a Date
      "title": "Close up of an apple on a tree",
      "type": "mp4",
              ^^^^^ Must be one of 'jpg', 'png'
      "size": 92357232,
      "url": "https://www.example.com/images/248",
    },
    ^ Missing key: 'id' (at index 0)
    {
      "id": 295,
      "created": new Date('2026-03-27T14:37:25.134Z'),
      "title": "Our apples in the final packaging",
      "type": "jpg",
      "size": 83247232,
    },
    {
      "id": 723,
      "created": new Date('2026-03-27T14:37:25.134Z'),
      "title": "Our fruit fields at Lake Constance",
      "type": "jpg",
      "size": 72356345,
      "url": "https://www.example.com/images/723",
    },
  ],
  "ratings": [
    {
      "id": 315,
      "stars": 4.5,
      "title": "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean ..." [truncated],
      "text": "Tastes super delicious",
      "images": [
        {
          "id": 835,
          "created": new Date('2026-03-27T14:37:25.134Z'),
          "title": "The result of our apple pie",
          "type": "jpg",
          "size": 8247493,
          "url": "https://www.example.com/images/835",
        },
      ],
    },
    {
      "id": 642,
      "stars": 5,
      "title": "Very tasty! I will buy them again!",
      "text": "In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. N..." [truncated],
      "images": [
        {
          "id": "352",
                ^^^^^ Must be number
          "created": undefined,
          "title": "The fruit salad in a bowl",
          "type": "jpg",
          "size": 3582543,
          "url": "INVALID_URL",
                 ^^^^^^^^^^^^^ Must be URL
        },
        ^ Missing key: 'created' (at index 0)
        {
          "id": 465,
          "created": new Date('2026-03-27T14:37:25.134Z'),
          "url": "https://www.example.com/images/465",
        },
      ],
    },
    ^ index 1
  ],
}
    at format (file:///node_modules/.pnpm/decoders@2.9.1/node_modules/decoders/dist/index.js:332:18)
    at Object.verify (file:///node_modules/.pnpm/decoders@2.9.1/node_modules/decoders/dist/index.js:351:13)
    at Object.throw (file:///schemas/dist/benchmarks-C3NafiWZ.js:80:6)
    at file:///bench/src/scripts/stack/log.ts:24:28
2.9.141.68K3
98
superstruct
Code snippetCode snippet
assert(data, schema)
Error outputError output
StructError: At path: title -- Expected a value of type `string`, but received: `""`
    at validate (/node_modules/.pnpm/superstruct@2.0.2/node_modules/superstruct/dist/index.cjs:298:27)
    at assert (/node_modules/.pnpm/superstruct@2.0.2/node_modules/superstruct/dist/index.cjs:254:24)
    at Object.throw (file:///schemas/dist/benchmarks-Dg2Rpi2X.js:109:4)
    at file:///bench/src/scripts/stack/log.ts:24:28 {
  value: '',
  type: 'string',
  refinement: 'string with length between 1 and 100',
  key: 'title',
  path: [ 'title' ],
  branch: [
    {
      id: 252,
      created: 2026-03-27T14:37:26.622Z,
      title: '',
      brand: 'Sunny Backyard',
      description: 'Red apple from Lake Constance',
      price: 0,
      discount: null,
      quantity: 1000,
      tags: [Array],
      images: [Array],
      ratings: [Array]
    },
    ''
  ],
  failures: [Function (anonymous)]
}
2.0.24.08M3
29
zod/v3
Code snippetCode snippet
schema.parse(data)
Error outputError output
ZodError: [
  {
    "code": "too_small",
    "minimum": 1,
    "type": "string",
    "inclusive": true,
    "exact": false,
    "message": "String must contain at least 1 character(s)",
    "path": [
      "title"
    ]
  },
  {
    "code": "too_small",
    "minimum": 1,
    "type": "number",
    "inclusive": true,
    "exact": false,
    "message": "Number must be greater than or equal to 1",
    "path": [
      "price"
    ]
  },
  {
    "code": "too_big",
    "maximum": 10,
    "type": "number",
    "inclusive": true,
    "exact": false,
    "message": "Number must be less than or equal to 10",
    "path": [
      "quantity"
    ]
  },
  {
    "code": "invalid_type",
    "expected": "string",
    "received": "null",
    "path": [
      "tags",
      1
    ],
    "message": "Expected string, received null"
  },
  {
    "code": "invalid_type",
    "expected": "string",
    "received": "undefined",
    "path": [
      "tags",
      3
    ],
    "message": "Required"
  },
  {
    "code": "invalid_type",
    "expected": "number",
    "received": "undefined",
    "path": [
      "images",
      0,
      "id"
    ],
    "message": "Required"
  },
  {
    "code": "invalid_type",
    "expected": "date",
    "received": "null",
    "path": [
      "images",
      0,
      "created"
    ],
    "message": "Expected date, received null"
  },
  {
    "received": "mp4",
    "code": "invalid_enum_value",
    "options": [
      "jpg",
      "png"
    ],
    "path": [
      "images",
      0,
      "type"
    ],
    "message": "Invalid enum value. Expected 'jpg' | 'png', received 'mp4'"
  },
  {
    "code": "invalid_type",
    "expected": "string",
    "received": "undefined",
    "path": [
      "images",
      1,
      "url"
    ],
    "message": "Required"
  },
  {
    "code": "invalid_type",
    "expected": "number",
    "received": "string",
    "path": [
      "ratings",
      1,
      "images",
      0,
      "id"
    ],
    "message": "Expected number, received string"
  },
  {
    "code": "invalid_type",
    "expected": "date",
    "received": "undefined",
    "path": [
      "ratings",
      1,
      "images",
      0,
      "created"
    ],
    "message": "Required"
  },
  {
    "validation": "url",
    "code": "invalid_string",
    "message": "Invalid url",
    "path": [
      "ratings",
      1,
      "images",
      0,
      "url"
    ]
  },
  {
    "code": "invalid_type",
    "expected": "string",
    "received": "undefined",
    "path": [
      "ratings",
      1,
      "images",
      1,
      "title"
    ],
    "message": "Required"
  },
  {
    "expected": "'jpg' | 'png'",
    "received": "undefined",
    "code": "invalid_type",
    "path": [
      "ratings",
      1,
      "images",
      1,
      "type"
    ],
    "message": "Required"
  },
  {
    "code": "invalid_type",
    "expected": "number",
    "received": "undefined",
    "path": [
      "ratings",
      1,
      "images",
      1,
      "size"
    ],
    "message": "Required"
  }
]
    at get error (file:///node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/types.js:39:31)
    at ZodObject.parse (file:///node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/types.js:114:22)
    at Object.throw (file:///schemas/dist/benchmarks-BTge1a8o.js:75:6)
    at file:///bench/src/scripts/stack/log.ts:24:28 {
  issues: [
    {
      code: 'too_small',
      minimum: 1,
      type: 'string',
      inclusive: true,
      exact: false,
      message: 'String must contain at least 1 character(s)',
      path: [Array]
    },
    {
      code: 'too_small',
      minimum: 1,
      type: 'number',
      inclusive: true,
      exact: false,
      message: 'Number must be greater than or equal to 1',
      path: [Array]
    },
    {
      code: 'too_big',
      maximum: 10,
      type: 'number',
      inclusive: true,
      exact: false,
      message: 'Number must be less than or equal to 10',
      path: [Array]
    },
    {
      code: 'invalid_type',
      expected: 'string',
      received: 'null',
      path: [Array],
      message: 'Expected string, received null'
    },
    {
      code: 'invalid_type',
      expected: 'string',
      received: 'undefined',
      path: [Array],
      message: 'Required'
    },
    {
      code: 'invalid_type',
      expected: 'number',
      received: 'undefined',
      path: [Array],
      message: 'Required'
    },
    {
      code: 'invalid_type',
      expected: 'date',
      received: 'null',
      path: [Array],
      message: 'Expected date, received null'
    },
    {
      received: 'mp4',
      code: 'invalid_enum_value',
      options: [Array],
      path: [Array],
      message: "Invalid enum value. Expected 'jpg' | 'png', received 'mp4'"
    },
    {
      code: 'invalid_type',
      expected: 'string',
      received: 'undefined',
      path: [Array],
      message: 'Required'
    },
    {
      code: 'invalid_type',
      expected: 'number',
      received: 'string',
      path: [Array],
      message: 'Expected number, received string'
    },
    {
      code: 'invalid_type',
      expected: 'date',
      received: 'undefined',
      path: [Array],
      message: 'Required'
    },
    {
      validation: 'url',
      code: 'invalid_string',
      message: 'Invalid url',
      path: [Array]
    },
    {
      code: 'invalid_type',
      expected: 'string',
      received: 'undefined',
      path: [Array],
      message: 'Required'
    },
    {
      expected: "'jpg' | 'png'",
      received: 'undefined',
      code: 'invalid_type',
      path: [Array],
      message: 'Required'
    },
    {
      code: 'invalid_type',
      expected: 'number',
      received: 'undefined',
      path: [Array],
      message: 'Required'
    }
  ],
  addIssue: [Function (anonymous)],
  addIssues: [Function (anonymous)]
}
4.3.6145.61M3
299
effect
Code snippetCode snippet
// const decodeAll = Schema.decodeUnknownEither(
//  schema, 
//  { errors: "all" }
// );
Effect.runSync(decodeAll(data));

(Commented code is not benchmarked)

Error outputError output
(FiberFailure) ParseError: { readonly id: number; readonly created: Date; readonly title: minLength(1) & maxLength(100); readonly brand: minLength(1) & maxLength(30); readonly description: minLength(1) & maxLength(500); readonly price: greaterThanOrEqualTo(1) & lessThanOrEqualTo(10000); readonly discount: greaterThanOrEqualTo(1) & lessThanOrEqualTo(100) | null; readonly quantity: greaterThanOrEqualTo(1) & lessThanOrEqualTo(10); readonly tags: ReadonlyArray<minLength(1) & maxLength(30)>; readonly images: ReadonlyArray<{ readonly id: number; readonly created: Date; readonly title: minLength(1) & maxLength(100); readonly type: "jpg" | "png"; readonly size: number; readonly url: { string | filter } }>; readonly ratings: ReadonlyArray<{ readonly id: number; readonly stars: greaterThanOrEqualTo(0) & lessThanOrEqualTo(5); readonly title: minLength(1) & maxLength(100); readonly text: minLength(1) & maxLength(1000); readonly images: ReadonlyArray<{ readonly id: number; readonly created: Date; readonly title: minLength(1) & maxLength(100); readonly type: "jpg" | "png"; readonly size: number; readonly url: { string | filter } }> }> }
├─ ["title"]
│  └─ minLength(1) & maxLength(100)
│     └─ From side refinement failure
│        └─ minLength(1)
│           └─ Predicate refinement failure
│              └─ Expected a string at least 1 character(s) long, actual ""
├─ ["price"]
│  └─ greaterThanOrEqualTo(1) & lessThanOrEqualTo(10000)
│     └─ From side refinement failure
│        └─ greaterThanOrEqualTo(1)
│           └─ Predicate refinement failure
│              └─ Expected a number greater than or equal to 1, actual 0
├─ ["quantity"]
│  └─ greaterThanOrEqualTo(1) & lessThanOrEqualTo(10)
│     └─ Predicate refinement failure
│        └─ Expected a number less than or equal to 10, actual 1000
├─ ["tags"]
│  └─ ReadonlyArray
│     ├─ [1]
│     │  └─ minLength(1) & maxLength(30)
│     │     └─ From side refinement failure
│     │        └─ minLength(1)
│     │           └─ From side refinement failure
│     │              └─ Expected string, actual null
│     └─ [3]
│        └─ minLength(1) & maxLength(30)
│           └─ From side refinement failure
│              └─ minLength(1)
│                 └─ From side refinement failure
│                    └─ Expected string, actual undefined
├─ ["images"]
│  └─ ReadonlyArray<{ readonly id: number; readonly created: Date; readonly title: minLength(1) & maxLength(100); readonly type: "jpg" | "png"; readonly size: number; readonly url: { string | filter } }>
│     ├─ [0]
│     │  └─ { readonly id: number; readonly created: Date; readonly title: minLength(1) & maxLength(100); readonly type: "jpg" | "png"; readonly size: number; readonly url: { string | filter } }
│     │     ├─ ["id"]
│     │     │  └─ is missing
│     │     ├─ ["created"]
│     │     │  └─ Expected Date, actual null
│     │     └─ ["type"]
│     │        └─ "jpg" | "png"
│     │           ├─ Expected "jpg", actual "mp4"
│     │           └─ Expected "png", actual "mp4"
│     └─ [1]
│        └─ { readonly id: number; readonly created: Date; readonly title: minLength(1) & maxLength(100); readonly type: "jpg" | "png"; readonly size: number; readonly url: { string | filter } }
│           └─ ["url"]
│              └─ is missing
└─ ["ratings"]
   └─ ReadonlyArray<{ readonly id: number; readonly stars: greaterThanOrEqualTo(0) & lessThanOrEqualTo(5); readonly title: minLength(1) & maxLength(100); readonly text: minLength(1) & maxLength(1000); readonly images: ReadonlyArray<{ readonly id: number; readonly created: Date; readonly title: minLength(1) & maxLength(100); readonly type: "jpg" | "png"; readonly size: number; readonly url: { string | filter } }> }>
      └─ [1]
         └─ { readonly id: number; readonly stars: greaterThanOrEqualTo(0) & lessThanOrEqualTo(5); readonly title: minLength(1) & maxLength(100); readonly text: minLength(1) & maxLength(1000); readonly images: ReadonlyArray<{ readonly id: number; readonly created: Date; readonly title: minLength(1) & maxLength(100); readonly type: "jpg" | "png"; readonly size: number; readonly url: { string | filter } }> }
            └─ ["images"]
               └─ ReadonlyArray<{ readonly id: number; readonly created: Date; readonly title: minLength(1) & maxLength(100); readonly type: "jpg" | "png"; readonly size: number; readonly url: { string | filter } }>
                  ├─ [0]
                  │  └─ { readonly id: number; readonly created: Date; readonly title: minLength(1) & maxLength(100); readonly type: "jpg" | "png"; readonly size: number; readonly url: { string | filter } }
                  │     ├─ ["id"]
                  │     │  └─ Expected number, actual "352"
                  │     ├─ ["created"]
                  │     │  └─ Expected Date, actual undefined
                  │     └─ ["url"]
                  │        └─ { string | filter }
                  │           └─ Predicate refinement failure
                  │              └─ Expected { string | filter }, actual "INVALID_URL"
                  └─ [1]
                     └─ { readonly id: number; readonly created: Date; readonly title: minLength(1) & maxLength(100); readonly type: "jpg" | "png"; readonly size: number; readonly url: { string | filter } }
                        ├─ ["title"]
                        │  └─ is missing
                        ├─ ["type"]
                        │  └─ is missing
                        └─ ["size"]
                           └─ is missing
    at parseError (file:///node_modules/.pnpm/effect@3.21.0/node_modules/effect/dist/esm/ParseResult.js:241:36)
    at file:///node_modules/.pnpm/effect@3.21.0/node_modules/effect/dist/esm/Either.js:197:78
    at Module. (file:///node_modules/.pnpm/effect@3.21.0/node_modules/effect/dist/esm/Function.js:98:18)
    at file:///node_modules/.pnpm/effect@3.21.0/node_modules/effect/dist/esm/Schema.js:353:42
    at Object.throw (file:///schemas/dist/benchmarks-DA1m2IjD.js:121:14)
    at file:///bench/src/scripts/stack/log.ts:24:28
3.21.09M5
78
sury
Code snippetCode snippet
S.parseOrThrow(data, schema)
Error outputError output
SuryError: Failed parsing at ["title"]: String must be 1 or more characters long
    at $$throw (/node_modules/.pnpm/sury@11.0.0-alpha.4/node_modules/sury/src/Sury.res.js:776:9)
    at Array.<anonymous> (/node_modules/.pnpm/sury@11.0.0-alpha.4/node_modules/sury/src/Sury.res.js:792:25)
    at eval (eval at internalCompile (/node_modules/.pnpm/sury@11.0.0-alpha.4/node_modules/sury/src/Sury.res.js:1418:10), <anonymous>:3:414)
    at Module.parseOrThrow (/node_modules/.pnpm/sury@11.0.0-alpha.4/node_modules/sury/src/Sury.res.js:1524:32)
    at Object.throw (file:///schemas/dist/benchmarks-NRYuHeY_.js:122:6)
    at file:///bench/src/scripts/stack/log.ts:24:28 {
  flag: 1,
  code: {
    TAG: 'OperationFailed',
    _0: 'String must be 1 or more characters long'
  },
  path: '["title"]'
}
11.0.0-alpha.4131.08K5
15
typia
Code snippetCode snippet
// const assert = typia.createAssert<TypiaSchema>();
assert(data);

(Commented code is not benchmarked)

Error outputError output
TypeGuardError: Error on typia.createAssert(): invalid type on $input.title, expect to be string & MinLength<1>
    at Module._assertGuard (file:///node_modules/.pnpm/typia@12.0.1_@types+node@25.5.0_typescript@6.0.2/node_modules/typia/lib/internal/_assertGuard.mjs:8:19)
    at i (file:///schemas/dist/benchmarks-QTPGD45F.js:307:69)
    at file:///schemas/dist/benchmarks-QTPGD45F.js:583:12
    at file:///schemas/dist/benchmarks-QTPGD45F.js:588:8
    at Object.throw (file:///schemas/dist/benchmarks-QTPGD45F.js:1268:4)
    at file:///bench/src/scripts/stack/log.ts:24:28 {
  method: 'typia.createAssert',
  path: '$input.title',
  expected: 'string & MinLength<1>',
  value: '',
  description: undefined,
  fake_expected_typed_value_: undefined
}
12.0.1281.1K5
15
effect@beta
Code snippetCode snippet
Schema.decodeUnknownSync(schema)(data, { errors: "first" })
Error outputError output
Error: Expected a value with a length of at least 1, got ""
  at ["title"]
    at file:///node_modules/.pnpm/effect@4.0.0-beta.40/node_modules/effect/dist/SchemaParser.js:303:99
    at file:///node_modules/.pnpm/effect@4.0.0-beta.40/node_modules/effect/dist/internal/effect.js:1068:19
    at file:///node_modules/.pnpm/effect@4.0.0-beta.40/node_modules/effect/dist/Function.js:94:18
    at file:///node_modules/.pnpm/effect@4.0.0-beta.40/node_modules/effect/dist/internal/effect.js:1019:85
    at Module.<anonymous> (file:///node_modules/.pnpm/effect@4.0.0-beta.40/node_modules/effect/dist/Function.js:94:18)
    at file:///node_modules/.pnpm/effect@4.0.0-beta.40/node_modules/effect/dist/SchemaParser.js:303:52
    at Object.throw (file:///schemas/dist/benchmarks-DA28dbtq.js:119:26)
    at file:///bench/src/scripts/stack/log.ts:24:28 {
  [cause]: Composite {
    '~effect/SchemaIssue/Issue': '~effect/SchemaIssue/Issue',
    _tag: 'Composite',
    ast: Objects {
      '~effect/Schema': '~effect/Schema',
      annotations: undefined,
      checks: undefined,
      encoding: undefined,
      context: undefined,
      _tag: 'Objects',
      propertySignatures: [Array],
      indexSignatures: []
    },
    actual: { _id: 'Option', _tag: 'Some', value: [Object] },
    issues: [ [Pointer] ]
  }
}
4.0.0-beta.409M7
28
arktype
Code snippetCode snippet
schema.assert(data)
Error outputError output
TraversalError: 
  • images[0].created must be a Date (was null)
  • images[0].id must be a number (was missing)
  • images[0].type must be "jpg" or "png" (was "mp4")
  • images[1].url must be a string (was missing)
  • price must be at least 1 (was 0)
  • quantity must be at most 10 (was 1000)
  • ratings[1].images[0].created must be a Date (was undefined)
  • ratings[1].images[0].id must be a number (was a string)
  • ratings[1].images[0].url must be a URL string (was "INVALID_URL")
  • ratings[1].images[1].size must be a number (was missing)
  • ratings[1].images[1].title must be a string (was missing)
  • ratings[1].images[1].type must be "jpg" or "png" (was missing)
  • tags[1] must be a string (was null)
  • tags[3] must be a string (was undefined)
  • title must be non-empty
    at ArkErrors.toTraversalError (file:///node_modules/.pnpm/@ark+schema@0.56.0/node_modules/@ark/schema/out/shared/errors.js:146:16)
    at ArkErrors.throw (file:///node_modules/.pnpm/@ark+schema@0.56.0/node_modules/@ark/schema/out/shared/errors.js:139:20)
    at file:///node_modules/.pnpm/@ark+schema@0.56.0/node_modules/@ark/schema/out/node.js:166:85
    at Traversal.finalize (file:///node_modules/.pnpm/@ark+schema@0.56.0/node_modules/@ark/schema/out/shared/traversal.js:112:29)
    at IntersectionNode.rootApply (file:///node_modules/.pnpm/@ark+schema@0.56.0/node_modules/@ark/schema/out/node.js:118:32)
    at BaseNode.attach (file:///node_modules/.pnpm/@ark+schema@0.56.0/node_modules/@ark/schema/out/node.js:33:25)
    at IntersectionNode.assert (file:///node_modules/.pnpm/@ark+schema@0.56.0/node_modules/@ark/schema/out/node.js:166:42)
    at Object.throw (file:///schemas/dist/benchmarks-D3XK3f0l.js:78:6)
    at file:///bench/src/scripts/stack/log.ts:24:28
2.2.0913.57K8
26
ajv
Code snippetCode snippet
// const validate = ajv.compile(schema);
validate(data);
throw new ValidationError(validate.errors || []);

(Commented code is not benchmarked)

Error outputError output
ValidationError: validation failed
    at Object.throw (file:///schemas/dist/benchmarks-7aRNXW8g.js:196:16)
    at file:///bench/src/scripts/stack/log.ts:24:28 {
  errors: [
    {
      instancePath: '/title',
      schemaPath: '#/properties/title/minLength',
      keyword: 'minLength',
      params: [Object],
      message: 'must NOT have fewer than 1 characters'
    }
  ],
  validation: true,
  ajv: true
}
8.18.0272.28M16
joi
Code snippetCode snippet
throw schema.validate(data).error
Error outputError output
[Error [ValidationError]: "title" is not allowed to be empty] {
  _original: {
    id: 252,
    created: 2026-03-27T14:37:26.354Z,
    title: '',
    brand: 'Sunny Backyard',
    description: 'Red apple from Lake Constance',
    price: 0,
    discount: null,
    quantity: 1000,
    tags: [ 'fruit', null, 'round', undefined, 'juicy', 'healthy' ],
    images: [ [Object], [Object], [Object] ],
    ratings: [ [Object], [Object] ]
  },
  details: [
    {
      message: '"title" is not allowed to be empty',
      path: [Array],
      type: 'string.empty',
      context: [Object]
    }
  ]
}
18.1.118.57M24
yup
Code snippetCode snippet
schema.validateSync(data)
Error outputError output
ValidationError: ratings[1].images[0].url must be a valid URL
    at createError (/node_modules/.pnpm/yup@1.7.1/node_modules/yup/index.js:352:21)
    at handleResult (/node_modules/.pnpm/yup@1.7.1/node_modules/yup/index.js:371:104)
    at validate (/node_modules/.pnpm/yup@1.7.1/node_modules/yup/index.js:394:5)
    at StringSchema.runTests (/node_modules/.pnpm/yup@1.7.1/node_modules/yup/index.js:855:7)
    at /node_modules/.pnpm/yup@1.7.1/node_modules/yup/index.js:810:12
    at nextOnce (/node_modules/.pnpm/yup@1.7.1/node_modules/yup/index.js:841:7)
    at finishTestRun (/node_modules/.pnpm/yup@1.7.1/node_modules/yup/index.js:860:11)
    at handleResult (/node_modules/.pnpm/yup@1.7.1/node_modules/yup/index.js:371:124)
    at validate (/node_modules/.pnpm/yup@1.7.1/node_modules/yup/index.js:394:5)
    at StringSchema.runTests (/node_modules/.pnpm/yup@1.7.1/node_modules/yup/index.js:855:7) {
  value: {
    ratings: [ [Object], [Object] ],
    images: [ [Object], [Object], [Object] ],
    tags: [ 'fruit', null, 'round', undefined, 'juicy', 'healthy' ],
    quantity: 1000,
    discount: null,
    price: 0,
    description: 'Red apple from Lake Constance',
    brand: 'Sunny Backyard',
    title: '',
    created: 2026-03-27T14:37:27.465Z,
    id: 252
  },
  path: 'ratings[1].images[0].url',
  type: 'url',
  params: {
    value: 'INVALID_URL',
    originalValue: 'INVALID_URL',
    label: undefined,
    path: 'ratings[1].images[0].url',
    spec: {
      strip: false,
      strict: false,
      abortEarly: true,
      recursive: true,
      disableStackTrace: false,
      nullable: false,
      optional: false,
      coerce: true
    },
    disableStackTrace: false,
    regex: /^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i
  },
  errors: [ 'ratings[1].images[0].url must be a valid URL' ],
  inner: [],
  Symbol(Symbol.toStringTag): 'Error'
}
1.7.110.53M49
zod
Code snippetCode snippet
schema.parse(data)
Error outputError output
ZodError: [
  {
    "origin": "string",
    "code": "too_small",
    "minimum": 1,
    "inclusive": true,
    "path": [
      "title"
    ],
    "message": "Too small: expected string to have >=1 characters"
  },
  {
    "origin": "number",
    "code": "too_small",
    "minimum": 1,
    "inclusive": true,
    "path": [
      "price"
    ],
    "message": "Too small: expected number to be >=1"
  },
  {
    "origin": "number",
    "code": "too_big",
    "maximum": 10,
    "inclusive": true,
    "path": [
      "quantity"
    ],
    "message": "Too big: expected number to be <=10"
  },
  {
    "expected": "string",
    "code": "invalid_type",
    "path": [
      "tags",
      1
    ],
    "message": "Invalid input: expected string, received null"
  },
  {
    "expected": "string",
    "code": "invalid_type",
    "path": [
      "tags",
      3
    ],
    "message": "Invalid input: expected string, received undefined"
  },
  {
    "expected": "number",
    "code": "invalid_type",
    "path": [
      "images",
      0,
      "id"
    ],
    "message": "Invalid input: expected number, received undefined"
  },
  {
    "expected": "date",
    "code": "invalid_type",
    "path": [
      "images",
      0,
      "created"
    ],
    "message": "Invalid input: expected date, received null"
  },
  {
    "code": "invalid_value",
    "values": [
      "jpg",
      "png"
    ],
    "path": [
      "images",
      0,
      "type"
    ],
    "message": "Invalid option: expected one of \"jpg\"|\"png\""
  },
  {
    "expected": "string",
    "code": "invalid_type",
    "path": [
      "images",
      1,
      "url"
    ],
    "message": "Invalid input: expected string, received undefined"
  },
  {
    "expected": "number",
    "code": "invalid_type",
    "path": [
      "ratings",
      1,
      "images",
      0,
      "id"
    ],
    "message": "Invalid input: expected number, received string"
  },
  {
    "expected": "date",
    "code": "invalid_type",
    "path": [
      "ratings",
      1,
      "images",
      0,
      "created"
    ],
    "message": "Invalid input: expected date, received undefined"
  },
  {
    "code": "invalid_format",
    "format": "url",
    "path": [
      "ratings",
      1,
      "images",
      0,
      "url"
    ],
    "message": "Invalid URL"
  },
  {
    "expected": "string",
    "code": "invalid_type",
    "path": [
      "ratings",
      1,
      "images",
      1,
      "title"
    ],
    "message": "Invalid input: expected string, received undefined"
  },
  {
    "code": "invalid_value",
    "values": [
      "jpg",
      "png"
    ],
    "path": [
      "ratings",
      1,
      "images",
      1,
      "type"
    ],
    "message": "Invalid option: expected one of \"jpg\"|\"png\""
  },
  {
    "expected": "number",
    "code": "invalid_type",
    "path": [
      "ratings",
      1,
      "images",
      1,
      "size"
    ],
    "message": "Invalid input: expected number, received undefined"
  }
]
    at Object.throw (file:///schemas/dist/benchmarks-5dkcoBLa.js:86:6)
    at file:///bench/src/scripts/stack/log.ts:24:28
4.3.6145.61M171
zod/mini
Code snippetCode snippet
schema.parse(data)
Error outputError output
$ZodError: [
  {
    "origin": "string",
    "code": "too_small",
    "minimum": 1,
    "inclusive": true,
    "path": [
      "title"
    ],
    "message": "Invalid input"
  },
  {
    "origin": "number",
    "code": "too_small",
    "minimum": 1,
    "inclusive": true,
    "path": [
      "price"
    ],
    "message": "Invalid input"
  },
  {
    "origin": "number",
    "code": "too_big",
    "maximum": 10,
    "inclusive": true,
    "path": [
      "quantity"
    ],
    "message": "Invalid input"
  },
  {
    "expected": "string",
    "code": "invalid_type",
    "path": [
      "tags",
      1
    ],
    "message": "Invalid input"
  },
  {
    "expected": "string",
    "code": "invalid_type",
    "path": [
      "tags",
      3
    ],
    "message": "Invalid input"
  },
  {
    "expected": "number",
    "code": "invalid_type",
    "path": [
      "images",
      0,
      "id"
    ],
    "message": "Invalid input"
  },
  {
    "expected": "date",
    "code": "invalid_type",
    "path": [
      "images",
      0,
      "created"
    ],
    "message": "Invalid input"
  },
  {
    "code": "invalid_value",
    "values": [
      "jpg",
      "png"
    ],
    "path": [
      "images",
      0,
      "type"
    ],
    "message": "Invalid input"
  },
  {
    "expected": "string",
    "code": "invalid_type",
    "path": [
      "images",
      1,
      "url"
    ],
    "message": "Invalid input"
  },
  {
    "expected": "number",
    "code": "invalid_type",
    "path": [
      "ratings",
      1,
      "images",
      0,
      "id"
    ],
    "message": "Invalid input"
  },
  {
    "expected": "date",
    "code": "invalid_type",
    "path": [
      "ratings",
      1,
      "images",
      0,
      "created"
    ],
    "message": "Invalid input"
  },
  {
    "code": "invalid_format",
    "format": "url",
    "path": [
      "ratings",
      1,
      "images",
      0,
      "url"
    ],
    "message": "Invalid input"
  },
  {
    "expected": "string",
    "code": "invalid_type",
    "path": [
      "ratings",
      1,
      "images",
      1,
      "title"
    ],
    "message": "Invalid input"
  },
  {
    "code": "invalid_value",
    "values": [
      "jpg",
      "png"
    ],
    "path": [
      "ratings",
      1,
      "images",
      1,
      "type"
    ],
    "message": "Invalid input"
  },
  {
    "expected": "number",
    "code": "invalid_type",
    "path": [
      "ratings",
      1,
      "images",
      1,
      "size"
    ],
    "message": "Invalid input"
  }
]
    at Object.throw (file:///schemas/dist/benchmarks-DrAZ9PLq.js:86:6)
    at file:///bench/src/scripts/stack/log.ts:24:28
4.3.6145.61M171
Created by eskimojo for Open Circle