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

    • deployed_code
      Libraries

    • article
      Blog
Expand sidebarExpand sidebar
Benchmarks/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.3Packagedeployed_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.0NativeNative 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
arktype
Code snippetCode snippet
schema.in.toJsonSchema({ target: "draft-2020-12" })
Generated JSON schemaGenerated JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ]
}
2.2.31.36MInput496 ns
arktype
Code snippetCode snippet
schema.out.toJsonSchema({ target: "draft-2020-12" })
Generated JSON schemaGenerated JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "number"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ]
}
2.2.31.36MOutput500 ns
1.01x
stat_minus_1
valibot
Code snippetCode snippet
toJsonSchema(schema, { target: "draft-2020-12", typeMode: "output" })
Generated JSON schemaGenerated JSON schema
{
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "number"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ],
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
1.4.216.77MOutput882 ns
1.78x
stat_minus_1
valibot
Code snippetCode snippet
toJsonSchema(schema, { target: "draft-2020-12", typeMode: "input" })
Generated JSON schemaGenerated JSON schema
{
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ],
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
1.4.216.77MInput905 ns
1.82x
stat_minus_1
effect@beta
Code snippetCode snippet
Schema.toJsonSchemaDocument(schema)
Generated JSON schemaGenerated JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "string",
          "enum": [
            "NaN"
          ]
        },
        {
          "type": "string",
          "enum": [
            "Infinity"
          ]
        },
        {
          "type": "string",
          "enum": [
            "-Infinity"
          ]
        }
      ]
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ],
  "additionalProperties": false,
  "$defs": {}
}
4.0.0-beta.10126.04MInput2 μs
3.48x
stat_minus_1
sury
Code snippetCode snippet
S.toJSONSchema(S.reverse(schema), { target: "draft-2020-12" })
Generated JSON schemaGenerated JSON schema
{
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "number"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ],
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
11.0.0-rc.0320.77KOutput2 μs
3.85x
stat_minus_1
sury
Code snippetCode snippet
S.toJSONSchema(schema, { target: "draft-2020-12" })
Generated JSON schemaGenerated JSON schema
{
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ],
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
11.0.0-rc.0320.77KInput2 μs
3.92x
stat_minus_1
effect
Code snippetCode snippet
JSONSchema.make(schema, { target: "jsonSchema2020-12" })
Generated JSON schemaGenerated JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/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.026.04MInput3 μs
6.12x
stat_minus_1
zod
Code snippetCode snippet
z.toJSONSchema(schema, { target: "draft-2020-12", io: "output" })
Generated JSON schemaGenerated JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "number"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ],
  "additionalProperties": false
}
4.4.3253.96MOutput7 μs
14.98x
stat_minus_3
zod/mini
Code snippetCode snippet
z.toJSONSchema(schema, { target: "draft-2020-12", io: "output" })
Generated JSON schemaGenerated JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "number"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ],
  "additionalProperties": false
}
4.4.3253.96MOutput8 μs
15.35x
stat_minus_3
zod/mini
Code snippetCode snippet
z.toJSONSchema(schema, { target: "draft-2020-12", io: "input" })
Generated JSON schemaGenerated JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ]
}
4.4.3253.96MInput9 μs
18.81x
stat_minus_3
effect
Code snippetCode snippet
JSONSchema.make(Schema.typeSchema(schema), { target: "jsonSchema2020-12" })
Generated JSON schemaGenerated JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "required": [
    "id",
    "name",
    "price"
  ],
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "number"
    }
  },
  "additionalProperties": false
}
3.22.026.04MOutput9 μs
18.91x
stat_minus_3
zod
Code snippetCode snippet
z.toJSONSchema(schema, { target: "draft-2020-12", io: "input" })
Generated JSON schemaGenerated JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "number"
    },
    "name": {
      "type": "string"
    },
    "price": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "name",
    "price"
  ]
}
4.4.3253.96MInput10 μs
19.2x
stat_minus_3
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser
Code ligatures