Make a JSON Schema of a JSON document: the types of its values, the members its objects have, and what its strings are, as formats and patterns you can change. It runs in your browser.
What it makes
Put a document in the box. The schema says the types of its values, the members of its objects and which of them every one has. The elements of an array are one place: a list of a thousand orders makes one schema of an order.
Patterns in strings
What every string at a place is (a date or a time, a uuid, an email, a web address, a host name, an IPv4, IPv6 or MAC address, a phone number, a version, a number written as text, a code of one shape such as ORD-2024-00017, or a list of them with , ; or | between) is written as a format and a pattern. An object whose keys are ids or dates is a map, under patternProperties, and phone1, phone2 are one pattern. The schema is checked against the document before you see it.
Changing it
The patterns and enums found are listed under the schema. Click one to see it in the schema and in the document (⏶ ⏷ step through its other places), then write another expression, make it a plain string, leave values out of an enum or add some, or restore what was found. You can type in the schema too. Reset undoes it all; Use in Validate checks the document against the schema as it is then.
Options
The draft it is written for (2020-12, 2019-09, 7, 6 or 4); Patterns; Required; No other keys, that is no members but those seen (additionalProperties: false); Enums, for a few strings that come again and again; and Bounds, the least and the most seen. Bounds fit the document exactly: loosen them by hand before the schema checks other documents.
In your tab
The schema is made by the same Rust engine as the desktop app, compiled to WebAssembly: nothing is uploaded. It shares its module, about 500 KB, with Validate. Up to 10 MB a box here.
Lessons
Samples to study and to try: ▶ Try it puts them in the page.
From a document to a schema
Create Schema writes the schema of a document: the types of its values, the members of its objects and which of them every one has. The elements of an array are one place: a list of records makes one schema of a record.
Three users, one schema of a user
Draft 2020-12 · Patterns · Required
Samples: Document
Document
[
{ "name": "Ada", "age": 36, "admin": true, "email": "[email protected]",
"skills": ["rust", "sql"] },
{ "name": "Linus", "age": 28, "admin": false, "email": null,
"skills": ["c"] },
{ "name": "Grace", "age": 45.5, "admin": false, "skills": [] }
]What it gives: 5 properties · 1 pattern
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"age": {
"type": "number"
},
"admin": {
"type": "boolean"
},
"email": {
"type": [
"string",
"null"
],
"format": "email",
"pattern": "^[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\\.[A-Za-z0-9-]+)*\\.[A-Za-z]{2,}$"
},
"skills": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"name",
"age",
"admin",
"skills"
]
}
}
Patterns found:
.[].email email · format email
^[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}$email is not required: Grace has none. It is a string or null.age is a number: 45.5 is among the whole numbers.skills is an array of strings, its elements from all three users.
Patterns in strings
What every string at a place is — a date, a uuid, an address, a code of one shape — is said as a format, where JSON Schema has one, and as a pattern, the regular expression they match. The list under the schema shows them all.
Orders with ids, dates, addresses and codes
Draft 2020-12 · Patterns · Required
Samples: Document
Document
[
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"number": "ORD-2024-00017",
"placed": "2024-01-15T10:30:00Z",
"email": "[email protected]",
"ip": "192.168.0.10",
"site": "https://shop.example.com/orders/17",
"zip": "90210",
"total": "25.50"
},
{
"id": "c56a4180-65aa-42ec-a945-5fd21dec0538",
"number": "ORD-2024-00230",
"placed": "2024-02-01T08:00:00+01:00",
"email": "[email protected]",
"ip": "10.0.0.1",
"site": "https://shop.example.com/orders/230",
"zip": "10001",
"total": "12.00"
}
]What it gives: 8 properties · 8 patterns
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
},
"number": {
"type": "string",
"pattern": "^ORD-[0-9]{4}-[0-9]{5}$"
},
"placed": {
"type": "string",
"format": "date-time",
"pattern": "^[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12][0-9]|3[01])T(?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]+)?(?:Z|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])$"
},
"email": {
"type": "string",
"format": "email",
"pattern": "^[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\\.[A-Za-z0-9-]+)*\\.[A-Za-z]{2,}$"
},
"ip": {
"type": "string",
"format": "ipv4",
"pattern": "^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])$"
},
"site": {
"type": "string",
"format": "uri",
"pattern": "^(?:https?|ftps?|wss?)://[^\\s/?#]+(?:[/?#][^\\s]*)?$"
},
"zip": {
"type": "string",
"pattern": "^[0-9]{5}$"
},
"total": {
"type": "string",
"pattern": "^[0-9]+\\.[0-9]{2}$"
}
},
"required": [
"id",
"number",
"placed",
"email",
"ip",
"site",
"zip",
"total"
]
}
}
Patterns found:
.[].id uuid · format uuid
^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
.[].number like ORD-2024-00017
^ORD-[0-9]{4}-[0-9]{5}$
.[].placed date-time · format date-time
^[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12][0-9]|3[01])T(?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\.[0-9]+)?(?:Z|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])$
.[].email email · format email
^[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}$
.[].ip IPv4 address · format ipv4
^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])$
.[].site URL · format uri
^(?:https?|ftps?|wss?)://[^\s/?#]+(?:[/?#][^\s]*)?$
.[].zip integer as text
^[0-9]{5}$
.[].total decimal as text
^[0-9]+\.[0-9]{2}$id, placed, email, ip and site have their formats: uuid, date-time, email, ipv4, uri.ORD-2024-00017 and ORD-2024-00230 have one shape: the letters both have are written as they are, the widths they agree on as {4} and {5}.zip and total are numbers written as text: five digits, and two decimals.- The schema is checked against the document before it is shown: the line under the list says The document fits it.
Good to know
- A click on a pattern in the list shows where it is, in the document and in the schema (⏶ and ⏷ step through the document), and opens it: write another expression and Apply, make it a Plain string, or Restore what was found.
- The schema is in a box: type in it too. Reset undoes every change.
Lists, maps and numbered keys
A string can hold a list — items of one kind with a comma, a semicolon or a bar between — and the pattern says so. Keys can be data too: an object whose keys are all dates, ids or numbers is a map, and phone1, phone2 are one key with a number.
A customer with lists, a map and two phones
Draft 2020-12 · Patterns · Required
Samples: Document
Document
{
"name": "Ada",
"tags": "gift,express,priority",
"servers": "10.0.0.1; 10.0.0.2",
"phone1": "+44 20 7946 0958",
"phone2": "+44 20 7946 0959",
"visits": { "2024-01-15": 3, "2024-01-16": 5, "2024-01-20": 1 }
}What it gives: 4 properties · 5 patterns
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"tags": {
"type": "string",
"pattern": "^(?:[a-z]+(?:,[a-z]+)*)?$"
},
"servers": {
"type": "string",
"pattern": "^(?:(?:(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?:; ?(?:(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9]))*)?$"
},
"visits": {
"type": "object",
"patternProperties": {
"^[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12][0-9]|3[01])$": {
"type": "integer"
}
}
}
},
"patternProperties": {
"^phone[0-9]+$": {
"type": "string",
"pattern": "^\\+[0-9](?:[ .()-]{0,2}[0-9]){6,14}$"
}
},
"required": [
"name",
"tags",
"servers",
"visits"
]
}
Patterns found:
.tags comma-separated: words
^(?:[a-z]+(?:,[a-z]+)*)?$
.servers semicolon-separated: IPv4 address
^(?:(?:(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?:; ?(?:(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9]))*)?$
.visits keys: date
^[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12][0-9]|3[01])$
. numbered keys: phone1, phone2
^phone[0-9]+$
.phone<n> phone number
^\+[0-9](?:[ .()-]{0,2}[0-9]){6,14}$tags is words with commas between; servers IPv4 addresses with ; between.visits is keyed by dates: one schema for its values, under patternProperties.phone1 and phone2 are ^phone[0-9]+$: a phone3 would fit too.
Enums and bounds
Two options say more of the values: Enums makes a list of a few strings that come again and again, and Bounds says the least and the most that was seen.
Tickets, with enums and bounds
Draft 2020-12 · Patterns · Required · Enums · Bounds
Samples: Document
Document
[
{ "status": "open", "priority": 2, "title": "Login fails" },
{ "status": "closed", "priority": 1, "title": "Typo on the home page" },
{ "status": "open", "priority": 3, "title": "Export is slow" },
{ "status": "waiting", "priority": 2, "title": "Add dark mode" },
{ "status": "open", "priority": 5, "title": "Crash on start" }
]What it gives: 3 properties · 0 patterns · 1 enum
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array",
"items": {
"type": "object",
"properties": {
"status": {
"type": "string",
"enum": [
"open",
"closed",
"waiting"
],
"minLength": 4,
"maxLength": 7
},
"priority": {
"type": "integer",
"minimum": 1,
"maximum": 5
},
"title": {
"type": "string",
"minLength": 11,
"maxLength": 21
}
},
"required": [
"status",
"priority",
"title"
]
},
"minItems": 5,
"maxItems": 5
}status is one of open, closed, waiting; title is no enum — every title is different.priority is from 1 to 5, the titles from 11 to 21 characters long, and the array has 5 items.- Bounds fit the sample exactly: loosen them by hand before the schema checks other documents.
Good to know
- An enum is in the list of patterns too. A click opens its values: untick one to leave it out, write another and Add it, or make it a Plain string.
- Use in Validate takes the document and the schema to the Validate page, which checks one against the other; Save… downloads the schema.
Your own queries, schemas, patches, documents and web addresses, kept in folders, with a sample if you like. It is the desktop app's workspace: a folder of the app opens here. This needs JavaScript.