JSON Schema Validator: how to get Bulk, Draft 7, 2019-09, 2020-12 as JSON/CSV (API, Python, no code)
Validate a JSON document, or up to 1000 of them, against a JSON Schema (draft 7, 2019-09 or 2020-12) and list every error with its path. This guide shows the output fields, a working input, and
Python, JavaScript and cURL code for the Actor v0iddo/validate-json-schema on Apify.
Open JSON Schema Validator on Apify
What data you get
One row per result. Every row can be downloaded as JSON, CSV, Excel or HTML, or read through the API.
| Field | Label | Type | Example |
|---|---|---|---|
index | # | number | 0 |
valid | Valid | true/false | false |
count | Errors | number | 1 |
errors | Error details | list | [{"index": 0, "path": "/age", "message": "-3 is less than the minim... |
credits | number | 1 | |
ms | number | 1 |
Input example
This is the input that is pre-filled on the Actor page. Change the values for your own run.
{
"schema": {
"type": "object",
"required": [
"name",
"age"
],
"properties": {
"name": {
"type": "string"
},
"age": {
"type": "integer",
"minimum": 0
}
}
},
"instance": "{\"name\": \"Ada\", \"age\": -3}"
}
| Input field | Type | What it does |
|---|---|---|
schema (required) | object | The JSON Schema to validate against. |
instance | string | One JSON value to validate (any type, including null). |
instances | array | Up to 1000 JSON values validated against the same schema. |
draft | string | JSON Schema draft. auto follows the schema's $schema and defaults to 2020-12. |
items | array | Optional. A list of input objects with the same fields as above; every object is processed in its own right and the top-level fields act as shared defaults. |
Output sample
Real rows from a run of the Actor. Fields that name people are left out of the sample.
[
{
"index": 0,
"valid": false,
"errors": [
{
"index": 0,
"path": "/age",
"message": "-3 is less than the minimum of 0",
"validator": "minimum"
}
],
"count": 1,
"credits": 1,
"ms": 1
}
]
Code: Python, JavaScript and cURL
Get your API token in Apify Console under Settings, then Integrations. The Actor id is v0iddo/validate-json-schema.
Python (apify-client)
from apify_client import ApifyClient
client = ApifyClient("YOUR_APIFY_TOKEN")
run_input = {'schema': {'type': 'object',
'required': ['name', 'age'],
'properties': {'name': {'type': 'string'},
'age': {'type': 'integer', 'minimum': 0}}},
'instance': '{"name": "Ada", "age": -3}'}
run = client.actor("v0iddo/validate-json-schema").call(run_input=run_input)
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
print(item)
JavaScript (apify-client)
import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: 'YOUR_APIFY_TOKEN' });
const input = {
"schema": {
"type": "object",
"required": [
"name",
"age"
],
"properties": {
"name": {
"type": "string"
},
"age": {
"type": "integer",
"minimum": 0
}
}
},
"instance": "{\"name\": \"Ada\", \"age\": -3}"
};
const run = await client.actor('v0iddo/validate-json-schema').call(input);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
cURL
curl -X POST "https://api.apify.com/v2/acts/v0iddo~validate-json-schema/run-sync-get-dataset-items" \
-H "Authorization: Bearer YOUR_APIFY_TOKEN" \
-H "Content-Type: application/json" \
-d '{"schema": {"type": "object", "required": ["name", "age"], "properties": {"name": {"type": "string"}, "age": {"type": "integer", "minimum": 0}}}, "instance": "{\"name\": \"Ada\", \"age\": -3}"}'
Price
$1.91 per 1,000 results. You pay per result row. There is no separate charge per run. Higher Apify plans pay less per result, down to $1.34 per 1,000. See the pricing tab for your plan. A new Apify account gets $5 of platform credit every month.
FAQ
What data does the JSON Schema Validator return?
Each result is one row in an Apify dataset. Fields include index, valid, count, errors, credits, ms. The table above shows every field with an example value.
How do I use the JSON Schema Validator from Python?
Install the apify-client package, create a client with your Apify API token, call the Actor v0iddo/validate-json-schema with an input like the one above, and read the rows from the run's dataset. The Python snippet above does exactly that.
Can I use it without writing code?
Yes. Open the Actor page on Apify, fill in the input form (an example is already filled in), press Start, and download the results as JSON, CSV, Excel or HTML. You can also schedule runs there.
How much does it cost?
$1.91 per 1,000 results. You pay per result row. There is no separate charge per run. Higher Apify plans pay less per result, down to $1.34 per 1,000. A new Apify account gets $5 of platform credit every month.
How do I limit the number of results?
Set a maximum cost for a run in the run options on Apify, and the run stops when it is reached.
Can I send the results to Google Sheets, Make, Zapier or n8n?
Yes. Apify datasets connect to Google Sheets, Slack, Make, Zapier and n8n, and a webhook can call your own service when a run finishes. You can also export the dataset as JSON, CSV or Excel.
Open JSON Schema Validator on Apify
Related guides
- WHOIS Domain Lookup: WHOIS lookup for any domain: registrar, creation and expiry dates, domain age, days to expiry, name servers...
- Domain Availability Checker: Check if domains are available, in bulk: one row per domain with available or registered, registrar, creati...
- Time Zone Converter: Convert a date and time between IANA time zones with exact daylight-saving handling, inspect a zone's offse...