# JSON Schema Validator: Validate JSON and Datasets in Bulk (`ucchiii/json-schema-validator`) Actor

Validate JSON files, NDJSON or Apify datasets against a JSON Schema (Draft 2020-12, 2019-09, 7, 6, 4). One row per item with valid or not and every error with its path. Empty input = free demo.

- **URL**: https://apify.com/ucchiii/json-schema-validator.md
- **Developed by:** [Actor Factory](https://apify.com/ucchiii) (community)
- **Categories:** Developer tools, Automation, Integrations
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.42 / 1,000 validated items

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

**JSON Schema validator for bulk data: your scraper, API export or data feed keeps delivering records with missing fields and wrong types, and you only find out downstream. Give this Actor a JSON Schema and your data, and get one row per item: valid or not, and every error with its path.**

Point it at JSON or NDJSON file URLs, an Apify dataset (for example the output of a scraper run), or items you paste, and it checks each item against your schema with the Python `jsonschema` library. The draft (2020-12, 2019-09, 7, 6 or 4) is picked from the schema's `$schema` line. You pay per validated item — no monthly rent, and a bad schema, an unreadable file or the demo cost nothing.

**Try it free:** clear the input and press **Start** — a built-in sample schema is applied to four sample customer records, showing both valid and invalid rows (not charged; rows carry `_demo: true`).

### What you get

Schema (excerpt) and an item:

```json
{"type": "object", "required": ["id", "email", "age"], "properties": {"age": {"type": "integer", "minimum": 0}}}
{"id": 3, "email": "not-an-email", "age": -4}
```

Result row:

| index | source | valid | errorCount | errors |
|---|---|---|---|---|
| 3 | inline items | false | 2 | `[{"path": "/age", "message": "-4 is less than the minimum of 0", "validator": "minimum"}, ...]` |

- **One row per item**: `index`, `source` (file URL, `dataset:ID` or `inline items`), `sourceIndex`, `valid`, `errorCount`, and `errors` — a list of `{path, message, validator}` where `path` is a JSON Pointer such as `/address/zip` (empty = the item itself) and `validator` is the failed schema keyword (`required`, `type`, `minimum`, `enum`, `pattern`, ...).
- **Optionally the item itself** in each row (`item`), so you can fix or re-route the bad ones.
- **Only invalid items** option: write just the failures, still with a full count in the summary.
- **Run summary** in the key-value store (`SUMMARY`, also saved as `OUTPUT`): items checked, valid and invalid counts, valid percent, the most common errors by rule and path (array positions folded to `*`, e.g. `/lines/*/qty`), counts per source, input files that could not be read.
- Broken NDJSON lines and unreadable files get a free row that says what is wrong.

### How to use

1. **JSON Schema** — paste it, or give a **JSON Schema URL** (for example a raw GitHub link or a SchemaStore URL). Schema `$ref`s inside the document work; references to other URLs are not fetched.
2. **Data** — any mix of **file URLs** (`.json` array or single object, `.ndjson` / `.jsonl`), **Apify datasets**, and **items pasted as JSON**.
3. Optional: **Check formats** (enforce `email`, `uri`, `date`, `date-time`, `ipv4`, `uuid`, ... — off by default, as the specification treats formats as annotations), **Only invalid items**, **Include the item**, **Max errors listed per item**, **Max items**.

```json
{
  "schemaUrl": "https://example.com/schemas/order.schema.json",
  "fileUrls": ["https://example.com/exports/orders.ndjson"],
  "datasetIds": ["YOUR_DATASET_ID"],
  "onlyInvalid": true,
  "includeItem": true
}
```

### Pricing

Pay per event: **$0.0006 per validated item** (about $0.60 per 1,000), valid or invalid. With *Only invalid items* on, valid items are still checked and counted. Not charged: the empty-input demo, schemas that are not valid, files or datasets that cannot be read, and broken NDJSON lines. Set a maximum cost per run in Apify and the Actor stops when it is reached.

### Good to know

- Draft support follows `$schema`: `draft/2020-12`, `draft/2019-09`, `draft-07`, `draft-06`, `draft-04`. No `$schema` means 2020-12. Drafts differ (for example `exclusiveMinimum` is a boolean in Draft 4 and a number later), so set `$schema` to match how your schema was written.
- `errorCount` counts up to 1,000 errors per item; `errors` lists up to the limit you set (default 20), sorted by path.
- Limits: 100 file URLs and 20 MB per file, 5 MB for the schema, 100,000 items per run by default (up to 1,000,000). A JSON file is read whole, so for very large inputs use NDJSON or a dataset.
- Public files only: no logins, and links to internal networks are blocked. You are responsible for having the right to check the files you point it to.
- Messages quote the failing value (cut at 300 characters). They stay in your own Apify storage.

If this Actor saved you time, a rating on the Store helps others find it.

### More tools from the same developer

- [YAML to JSON Converter](https://apify.com/ucchiii/yaml-json-converter) — YAML to JSON and JSON to YAML from text or files, with syntax errors by line and column
- [Flatten JSON to CSV](https://apify.com/ucchiii/flatten-json) — flatten nested JSON into flat rows with the separator you choose
- [Filter CSV, JSON or Dataset Rows by Condition](https://apify.com/ucchiii/filter-rows) — keep only the rows of a CSV, JSON file or dataset that match simple conditions like country = US or price > 100
- [JSON to CSV Converter](https://apify.com/ucchiii/json-to-csv) — turn nested JSON files or datasets into one flat CSV file
- [Merge Datasets](https://apify.com/ucchiii/merge-datasets) — combine several datasets or CSV/JSON files into one, with columns aligned

# Actor input Schema

## `schema` (type: `object`):

The JSON Schema to check against, pasted as JSON. The draft (2020-12, 2019-09, 7, 6 or 4) is picked from its $schema line; without one, 2020-12 is used. Leave this, the schema URL and all data empty for a free demo.

## `schemaUrl` (type: `string`):

Optional. Public http(s) link to a JSON Schema file, for example a raw.githubusercontent.com link. Used when the JSON Schema field above is empty. Links to internal networks are blocked.

## `fileUrls` (type: `array`):

Public http(s) links to .json (an array of items, or one object) or .ndjson / .jsonl (one item per line) files, up to 20 MB each and 100 files per run.

## `datasetIds` (type: `array`):

Datasets to validate, for example the output of a scraper run. Each dataset item is one item to check. You can paste a dataset URL from Apify Console too.

## `items` (type: `array`):

Items to validate, as a JSON array. Each element is checked on its own against the schema.

## `onlyInvalid` (type: `boolean`):

Write only the items that fail the schema to the results. Valid items are still checked and counted (and charged), and the SUMMARY has the totals.

## `includeItem` (type: `boolean`):

Add the checked item itself to each result row, so you can fix or re-route the bad ones without a join.

## `checkFormats` (type: `boolean`):

Also enforce 'format' keywords such as email, uri, date, date-time, ipv4 and uuid. Off by default, as the JSON Schema specification treats formats as annotations.

## `maxErrorsPerItem` (type: `integer`):

How many errors to list in the errors field of one row. The errorCount field always shows how many were found (up to 1,000).

## `maxItems` (type: `integer`):

Stop after this many items in total, across all files, datasets and pasted items. A safety limit for your bill.

## Actor input object example

```json
{
  "schema": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "required": [
      "id",
      "email",
      "age"
    ],
    "properties": {
      "id": {
        "type": "integer",
        "minimum": 1
      },
      "email": {
        "type": "string",
        "format": "email"
      },
      "age": {
        "type": "integer",
        "minimum": 0,
        "maximum": 120
      },
      "role": {
        "enum": [
          "admin",
          "editor",
          "viewer"
        ]
      }
    },
    "additionalProperties": false
  },
  "items": [
    {
      "id": 1,
      "email": "ana@example.com",
      "age": 34,
      "role": "admin"
    },
    {
      "id": 2,
      "email": "ben@example.com",
      "age": 29
    },
    {
      "id": 3,
      "email": "not-an-email",
      "age": -4,
      "role": "boss"
    },
    {
      "id": "4",
      "age": 41,
      "nickname": "cj"
    }
  ],
  "onlyInvalid": false,
  "includeItem": false,
  "checkFormats": false,
  "maxErrorsPerItem": 20,
  "maxItems": 100000
}
```

# Actor output Schema

## `results` (type: `string`):

One row per checked item: valid or not, the number of errors and each error with its path, message and rule.

## `summary` (type: `string`):

Record SUMMARY: items checked, valid and invalid counts, the most common errors, and the charged items.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "schema": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "type": "object",
        "required": [
            "id",
            "email",
            "age"
        ],
        "properties": {
            "id": {
                "type": "integer",
                "minimum": 1
            },
            "email": {
                "type": "string",
                "format": "email"
            },
            "age": {
                "type": "integer",
                "minimum": 0,
                "maximum": 120
            },
            "role": {
                "enum": [
                    "admin",
                    "editor",
                    "viewer"
                ]
            }
        },
        "additionalProperties": false
    },
    "items": [
        {
            "id": 1,
            "email": "ana@example.com",
            "age": 34,
            "role": "admin"
        },
        {
            "id": 2,
            "email": "ben@example.com",
            "age": 29
        },
        {
            "id": 3,
            "email": "not-an-email",
            "age": -4,
            "role": "boss"
        },
        {
            "id": "4",
            "age": 41,
            "nickname": "cj"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("ucchiii/json-schema-validator").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "schema": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "type": "object",
        "required": [
            "id",
            "email",
            "age",
        ],
        "properties": {
            "id": {
                "type": "integer",
                "minimum": 1,
            },
            "email": {
                "type": "string",
                "format": "email",
            },
            "age": {
                "type": "integer",
                "minimum": 0,
                "maximum": 120,
            },
            "role": { "enum": [
                    "admin",
                    "editor",
                    "viewer",
                ] },
        },
        "additionalProperties": False,
    },
    "items": [
        {
            "id": 1,
            "email": "ana@example.com",
            "age": 34,
            "role": "admin",
        },
        {
            "id": 2,
            "email": "ben@example.com",
            "age": 29,
        },
        {
            "id": 3,
            "email": "not-an-email",
            "age": -4,
            "role": "boss",
        },
        {
            "id": "4",
            "age": 41,
            "nickname": "cj",
        },
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("ucchiii/json-schema-validator").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "schema": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "required": [
      "id",
      "email",
      "age"
    ],
    "properties": {
      "id": {
        "type": "integer",
        "minimum": 1
      },
      "email": {
        "type": "string",
        "format": "email"
      },
      "age": {
        "type": "integer",
        "minimum": 0,
        "maximum": 120
      },
      "role": {
        "enum": [
          "admin",
          "editor",
          "viewer"
        ]
      }
    },
    "additionalProperties": false
  },
  "items": [
    {
      "id": 1,
      "email": "ana@example.com",
      "age": 34,
      "role": "admin"
    },
    {
      "id": 2,
      "email": "ben@example.com",
      "age": 29
    },
    {
      "id": 3,
      "email": "not-an-email",
      "age": -4,
      "role": "boss"
    },
    {
      "id": "4",
      "age": 41,
      "nickname": "cj"
    }
  ]
}' |
apify call ucchiii/json-schema-validator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ucchiii/json-schema-validator"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/34y8uzrlJf2VhoTn2/builds/44K8Dy0yOxfIQwrBO/openapi.json
