Generate JSON Schema from sample JSON

Infer a first-pass JSON Schema from a sample document, including common string formats.

freeworks offlinenothing uploaded
ToolJSON Schema Generator
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

The sample is parsed and visited recursively: strings get simple date, email, URI, UUID, or IPv4 hints; numbers become integer or number; objects become properties; and arrays infer one item schema or oneOf alternatives. Draft metadata and optional required lists are then added to the formatted document.

  • Draft 7 is the widely supported starting dialect.
  • Required properties are enabled to describe the supplied sample completely.

Worked example

Generate from Object
Infer a JSON Schema from a sample user object with format detection
Input
											{
  "name": "Alice",
  "email": "[email protected]",
  "age": 30,
  "active": true
}
										
Output
												{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    },
    "email": {
      "type": "string",
      "format": "email"
    },
    "age": {
      "type": "integer"
    },
    "active": {
      "type": "boolean"
    }
  },
  "required": [
    "name",
    "email",
    "age",
    "active"
  ]
}
											

When to use this

API payloads, form generators, and fixture contract tests use inferred schemas as a starting point.

Edge cases

  • Mixed primitive arrays become oneOf alternatives instead of one forced type.
  • A nullable property is omitted from the required list.
  • A sample cannot reveal bounds, lengths, or cross-field constraints.

References