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
joi
Code snippetCode snippet
parse(schema, "json")
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.5n/aInput77 μs
zod
Code snippetCode snippet
z.toJSONSchema(schema, { target: "draft-07", io: "input" })
Generated JSON schemaGenerated JSON schema
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ]
}
4.4.3n/aInput9 μs
8.22x
stat_1
effect
Code snippetCode snippet
JSONSchema.make(Schema.typeSchema(schema), { target: "jsonSchema7" })
Generated JSON schemaGenerated JSON schema
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "required": [
    "id",
    "name",
    "price"
  ],
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "number"
    }
  },
  "additionalProperties": false
}
3.22.0n/aOutput9 μs
8.76x
stat_1
zod/mini
Code snippetCode snippet
z.toJSONSchema(schema, { target: "draft-07", io: "input" })
Generated JSON schemaGenerated JSON schema
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ]
}
4.4.3n/aInput9 μs
8.9x
stat_1
zod
Code snippetCode snippet
z.toJSONSchema(schema, { target: "draft-07", io: "output" })
Generated JSON schemaGenerated JSON schema
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "number"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ],
  "additionalProperties": false
}
4.4.3n/aOutput8 μs
9.88x
stat_1
zod/mini
Code snippetCode snippet
z.toJSONSchema(schema, { target: "draft-07", io: "output" })
Generated JSON schemaGenerated JSON schema
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "number"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ],
  "additionalProperties": false
}
4.4.3n/aOutput7 μs
11.24x
stat_1
zod/v3
Code snippetCode snippet
zodToJsonSchema(schema, { target: "jsonSchema7" })
Generated JSON schemaGenerated JSON schema
{
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ],
  "additionalProperties": false,
  "$schema": "http://json-schema.org/draft-07/schema#"
}
4.4.3n/aInput5 μs
14.58x
stat_1
zod/v3
Code snippetCode snippet
zodToJsonSchema(schema, { target: "jsonSchema7" })
Generated JSON schemaGenerated JSON schema
{
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "number"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ],
  "additionalProperties": false,
  "$schema": "http://json-schema.org/draft-07/schema#"
}
4.4.3n/aOutput5 μs
15.02x
stat_1
effect
Code snippetCode snippet
JSONSchema.make(schema, { target: "jsonSchema7" })
Generated JSON schemaGenerated JSON schema
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$defs": {
    "NumberFromString": {
      "type": "string",
      "description": "a string to be decoded into a number"
    }
  },
  "type": "object",
  "required": [
    "id",
    "name",
    "price"
  ],
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "$ref": "#/$defs/NumberFromString"
    }
  },
  "additionalProperties": false
}
3.22.0n/aInput3 μs
28.68x
stat_1
sury
Code snippetCode snippet
S.toJSONSchema(S.reverse(schema), { target: "draft-07" })
Generated JSON schemaGenerated JSON schema
{
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "number"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ],
  "$schema": "http://json-schema.org/draft-07/schema#"
}
11.0.0-rc.1n/aOutput2 μs
37.97x
stat_2
sury
Code snippetCode snippet
S.toJSONSchema(schema, { target: "draft-07" })
Generated JSON schemaGenerated JSON schema
{
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ],
  "$schema": "http://json-schema.org/draft-07/schema#"
}
11.0.0-rc.1n/aInput2 μs
40.96x
stat_2
valibot
Code snippetCode snippet
toJsonSchema(schema, { target: "draft-07", typeMode: "input" })
Generated JSON schemaGenerated JSON schema
{
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ],
  "$schema": "http://json-schema.org/draft-07/schema#"
}
1.4.2n/aInput878 ns
87.81x
stat_3
valibot
Code snippetCode snippet
toJsonSchema(schema, { target: "draft-07", typeMode: "output" })
Generated JSON schemaGenerated JSON schema
{
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "number"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ],
  "$schema": "http://json-schema.org/draft-07/schema#"
}
1.4.2n/aOutput864 ns
89.2x
stat_3
arktype
Code snippetCode snippet
schema.out.toJsonSchema({ target: "draft-07" })
Generated JSON schemaGenerated JSON schema
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "number"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ]
}
2.2.3n/aOutput728 ns
105.92x
stat_3
arktype
Code snippetCode snippet
schema.in.toJsonSchema({ target: "draft-07" })
Generated JSON schemaGenerated JSON schema
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ]
}
2.2.3n/aInput716 ns
107.66x
stat_3
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser
Code ligatures