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
JSON Schema/Schema to JSONSchema to JSON
github
GitHubGitHub
DiscordDiscord
PreferencesPreferences

Many libraries can convert a schema into a JSON Schema, so it can be consumed by anything that speaks JSON Schema - documentation generators, OpenAPI builders, LLM structured outputs.

We benchmark whichever API the library provides, using a small schema with a codec. Libraries that generate JSON schemas at build time (e.g. typia) are not included — there's nothing to time at runtime.

Copy to clipboardCopy to clipboard
const schema = z.object({ id: z.number(), name: z.string(), price: z.codec(z.string(), z.number(), { decode: Number, encode: String }), }); const jsonSchema = z.toJSONSchema(schema);

Because of the codec, the input and output types differ (price is a string going in, a number coming out), and so do their JSON schemas.

Standard JSON Schema

Some libraries also implement the Standard JSON Schema interface, which lets a tool generate a JSON schema without specialising for each library:

Copy to clipboardCopy to clipboard
const jsonSchema = personSchema["~standard"].jsonSchema.input({ target: "draft-2020-12" });

The Standard JSON Schema column shows how each library supports it:

  • Native - the library implements it
  • Native Opt in - implemented, but it has to be enabled first (e.g. S.enableStandardJSONSchema())
  • Separate package - a separate package implements it (e.g. @valibot/to-json-schema)
  • None (blank) - nothing implements it, so only the library's own API is benchmarked
format_quoteGenerated schemas

Every generated schema is checked against the data it describes, but libraries don't agree on what a JSON schema for the same type looks like - each result links to what its library generated.

grid_viewSupport MatrixspeedBenchmarks
Draft 2020-12Draft 07OpenAPI 3.0
LibraryVersionSourceStandard JSON SchemaInputOutputInputOutputInputOutput
arktype2.2.3NativeNative
Reason for lack of supportReason for lack of support
Unsupported JSON Schema target: openapi-3.0
Reason for lack of supportReason for lack of support
Unsupported JSON Schema target: openapi-3.0
effect@beta4.0.0-beta.101Native
Reason for lack of supportReason for lack of support
No JSON schema can be generated for the direction: output
Reason for lack of supportReason for lack of support
Unsupported JSON Schema target: draft-07
Reason for lack of supportReason for lack of support
Unsupported JSON Schema target: draft-07
Reason for lack of supportReason for lack of support
Unsupported JSON Schema target: openapi-3.0
Reason for lack of supportReason for lack of support
Unsupported JSON Schema target: openapi-3.0
effect3.22.0Native
Reason for lack of supportReason for lack of support
Unsupported JSON Schema target: openapi-3.0
Reason for lack of supportReason for lack of support
Unsupported JSON Schema target: openapi-3.0
joi18.2.5Packagedeployed_code
Package requiredPackage required
joi-to-json
Reason for lack of supportReason for lack of support
Unsupported JSON Schema target: draft-2020-12
Reason for lack of supportReason for lack of support
No JSON schema can be generated for the direction: output
Reason for lack of supportReason for lack of support
No JSON schema can be generated for the direction: output
Reason for lack of supportReason for lack of support
No JSON schema can be generated for the direction: output
sury11.0.0-rc.1NativeNative Opt in
valibot1.4.2Packagedeployed_code
Package requiredPackage required
@valibot/to-json-schema
Packagedeployed_code
Package requiredPackage required
@valibot/to-json-schema
zod4.4.3NativeNative
zod/mini4.4.3Native
zod/v34.4.3Packagedeployed_code
Package requiredPackage required
zod-to-json-schema
Reason for lack of supportReason for lack of support
Unsupported JSON Schema target: draft-2020-12
Reason for lack of supportReason for lack of support
Unsupported JSON Schema target: draft-2020-12
Target
  • data_objectDraft 2020-12
  • data_objectDraft 07
  • apiOpenAPI 3.0
Type
  • loginInput
  • logoutOutput
LibrarysortVersiondownload/wksortTypeMeanarrow_upwardCompare
valibot
Code snippetCode snippet
toJsonSchema(schema, { target: "openapi-3.0", typeMode: "output" })
Generated JSON schemaGenerated JSON schema
{
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "number"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ]
}
1.4.217.6MOutput860 ns
valibot
Code snippetCode snippet
toJsonSchema(schema, { target: "openapi-3.0", typeMode: "input" })
Generated JSON schemaGenerated JSON schema
{
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ]
}
1.4.217.6MInput870 ns
1.01x
stat_minus_1
sury
Code snippetCode snippet
S.toJSONSchema(schema, { target: "openapi-3.0" })
Generated JSON schemaGenerated JSON schema
{
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ]
}
11.0.0-rc.1291.73KInput2 μs
2.18x
stat_minus_1
sury
Code snippetCode snippet
S.toJSONSchema(S.reverse(schema), { target: "openapi-3.0" })
Generated JSON schemaGenerated JSON schema
{
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "number"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ]
}
11.0.0-rc.1291.73KOutput2 μs
2.31x
stat_minus_1
zod/v3
Code snippetCode snippet
zodToJsonSchema(schema, { target: "openApi3" })
Generated JSON schemaGenerated JSON schema
{
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "number"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ],
  "additionalProperties": false
}
4.4.3265.23MOutput5 μs
6.05x
stat_minus_1
zod/v3
Code snippetCode snippet
zodToJsonSchema(schema, { target: "openApi3" })
Generated JSON schemaGenerated JSON schema
{
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ],
  "additionalProperties": false
}
4.4.3265.23MInput5 μs
6.13x
stat_minus_1
zod/mini
Code snippetCode snippet
z.toJSONSchema(schema, { target: "openapi-3.0", io: "output" })
Generated JSON schemaGenerated JSON schema
{
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "number"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ],
  "additionalProperties": false
}
4.4.3265.23MOutput7 μs
7.69x
stat_minus_1
zod
Code snippetCode snippet
z.toJSONSchema(schema, { target: "openapi-3.0", io: "output" })
Generated JSON schemaGenerated JSON schema
{
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "number"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ],
  "additionalProperties": false
}
4.4.3265.23MOutput8 μs
8.75x
stat_minus_1
zod/mini
Code snippetCode snippet
z.toJSONSchema(schema, { target: "openapi-3.0", io: "input" })
Generated JSON schemaGenerated JSON schema
{
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ]
}
4.4.3265.23MInput8 μs
9.59x
stat_minus_1
zod
Code snippetCode snippet
z.toJSONSchema(schema, { target: "openapi-3.0", io: "input" })
Generated JSON schemaGenerated JSON schema
{
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ]
}
4.4.3265.23MInput9 μs
10.35x
stat_minus_1
joi
Code snippetCode snippet
parse(schema, "open-api")
Generated JSON schemaGenerated JSON schema
{
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ],
  "additionalProperties": false
}
18.2.524.9MInput83 μs
96.86x
stat_minus_3
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser
Code ligatures