JSON Validator
Pricing
Pay per event
JSON Validator
This actor validates JSON strings and reports syntax errors with positions. It also formats valid JSON, detects the type (object/array/string/number/boolean/null), counts keys or array elements, and measures nesting depth. Useful for data pipeline QA and bulk JSON validation.
Pricing
Pay per event
Rating
0.0
(0)
Developer

Stas Persiianenko
Actor stats
0
Bookmarked
2
Total users
1
Monthly active users
10 days ago
Last modified
Categories
Share
Validate and format JSON strings in bulk.
What does JSON Validator do?
This actor validates JSON strings and reports syntax errors with exact positions. It also formats valid JSON with proper indentation, detects the JSON type (object, array, string, number, boolean, or null), counts keys or array elements, and measures nesting depth. Ideal for data pipeline QA, API response validation, and bulk JSON checking.
Use cases
- Data engineer validating JSON outputs from ETL pipelines before loading into a data warehouse
- QA engineer verifying that API responses conform to expected structure and syntax
- Backend developer debugging malformed JSON payloads by pinpointing exact error positions
- DevOps engineer checking configuration files in bulk before deploying to production
- Technical writer formatting and prettifying JSON examples for documentation
Why use JSON Validator?
- Batch validation -- check hundreds of JSON strings in a single run instead of pasting them one by one into an online tool
- Exact error positions -- when JSON is invalid, get the precise character position and error message to speed up debugging
- Structure analysis -- automatically detect JSON type, count top-level keys or array elements, and measure nesting depth
- Pretty formatting -- valid JSON is returned with clean indentation, ready for documentation or logging
- Structured output -- every result is a clean JSON object with consistent fields for downstream processing
- Pay-per-event pricing -- only $0.0005 per string validated, plus a one-time start fee
Input parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
jsonStrings | string[] | Yes | -- | List of JSON strings to validate and format |
{"jsonStrings": ["{\"name\": \"test\", \"value\": 42}","{invalid json}","[1, 2, 3]"]}
Output example
Each JSON string produces a result object with the following fields:
| Field | Type | Description |
|---|---|---|
index | number | Position of this string in the input array |
input | string | The original JSON string |
isValid | boolean | Whether the JSON is syntactically valid |
type | string | JSON type: object, array, string, number, boolean, or null |
formatted | string | Pretty-printed JSON with indentation (if valid) |
keyCount | number | Number of top-level keys (for objects) |
arrayLength | number | Number of elements (for arrays) |
depth | number | Maximum nesting depth |
errorMessage | string | Description of the syntax error (if invalid) |
errorPosition | number | Character index where the error occurred (if invalid) |
{"index": 0,"input": "{\"name\": \"test\", \"value\": 42}","isValid": true,"type": "object","formatted": "{\n \"name\": \"test\",\n \"value\": 42\n}","keyCount": 2,"arrayLength": null,"depth": 1,"errorMessage": null,"errorPosition": null}
How much does it cost?
| Event | Price | Description |
|---|---|---|
| Start | $0.035 | One-time per run |
| JSON validated | $0.0005 | Per JSON string validated |
Example costs:
- 10 strings = $0.035 + (10 x $0.0005) = $0.04
- 100 strings = $0.035 + (100 x $0.0005) = $0.085
- 1,000 strings = $0.035 + (1,000 x $0.0005) = $0.535
Using the Apify API
You can start JSON Validator programmatically from your own applications using the Apify API. Below are examples in Node.js and Python.
Node.js
import { ApifyClient } from 'apify-client';const client = new ApifyClient({ token: 'YOUR_TOKEN' });const run = await client.actor('automation-lab/json-validator').call({jsonStrings: ['{"valid": true}', 'not json'],});const { items } = await client.dataset(run.defaultDatasetId).listItems();console.log(items);
Python
from apify_client import ApifyClientclient = ApifyClient('YOUR_TOKEN')run = client.actor('automation-lab/json-validator').call(run_input={'jsonStrings': ['{"valid": true}', 'not json'],})items = client.dataset(run['defaultDatasetId']).list_items().itemsprint(items)
Integrations
JSON Validator works with the full Apify integration ecosystem. You can connect it to a wide range of automation platforms and data destinations:
- Make (formerly Integromat) -- trigger JSON validation as a step in a multi-tool scenario
- Zapier -- validate JSON payloads automatically as part of your zap workflows
- n8n -- use the Apify node in n8n workflows for self-hosted data pipeline validation
- Slack -- send validation results or failure alerts to a Slack channel
- Google Sheets -- export validation results to a spreadsheet for review
- Amazon S3 -- store output datasets in S3 buckets for archival
- Webhooks -- send results to any HTTP endpoint for real-time monitoring
You can also schedule recurring runs on the Apify platform to validate new data on a timer and alert on failures.
Tips and best practices
- Escape strings properly -- when passing JSON strings through the API, remember that they need to be escaped within the outer JSON input object. Use raw string literals in Python or template literals in JavaScript to avoid double-escaping headaches.
- Filter results by
isValid-- after a run, filter the dataset for items whereisValidisfalseto quickly find and fix problematic entries. - Use
depthfor complexity checks -- deeply nested JSON (depth 5+) can cause performance issues in some parsers. Use the depth field to flag overly complex structures. - Combine with web scrapers -- validate JSON responses from scraped APIs automatically by chaining JSON Validator after a scraper run.
- Check
keyCountfor schema drift -- if you expect objects with a specific number of keys, use this field to detect when upstream data sources change their schema.
FAQ
What JSON standards does this actor support?
The actor uses the standard JavaScript JSON.parse() function, which implements the ECMA-404 / RFC 8259 JSON specification. It handles objects, arrays, strings, numbers, booleans, and null values.
Can I validate JSON against a specific schema (like JSON Schema)? This actor validates JSON syntax and structure, not schema compliance. It tells you whether the JSON is well-formed and provides structural metadata. For JSON Schema validation, you would need to process the output with a schema validator in your own code.
What does the errorPosition field contain?
When JSON is invalid, errorPosition contains the character index where the parser encountered the syntax error. This helps you locate the exact problem in the original string.
Does the actor handle JSON with comments or trailing commas?
No. The actor uses strict JSON parsing per the ECMA-404 standard. JSON with comments (// ... or /* ... */) or trailing commas will be reported as invalid. Strip comments and trailing commas before submitting if needed.


