JSONL Stream Validator avatar

JSONL Stream Validator

Pricing

Pay per usage

Go to Apify Store
JSONL Stream Validator

JSONL Stream Validator

Validate a stream of JSONL/NDJSON records against a JSON Schema (draft-07 subset) one line at a time. Per-record error rows, drop-or-tag policy, summary by error type. Pairs with json-schema-validator + jsonl-to-csv.

Pricing

Pay per usage

Rating

0.0

(0)

Developer

Nikita S

Nikita S

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

7 days ago

Last modified

Share

Validate a stream of JSONL/NDJSON records against a JSON Schema (draft-07 subset) one line at a time. Per-record error rows, drop-or-tag policy, summary by error code.

Pure JS, zero deps (the schema validator is a self-contained subset implementation, not a heavy npm dep). No HTTP calls unless you point jsonlUrl / schemaUrl at a public endpoint. Pairs with:

  • jsonl-to-csv (Batch 5) — convert validated JSONL to typed CSV
  • json-schema-validator (Batch 3) — validates the schema itself against meta-rules (use as a pre-check)

Why this Actor

The Apify Store has at least 5 JSON Schema validators, but every one of them:

  • takes the data as a single nested array (not a stream), which blows memory on big files;
  • lacks a draft-07 subset that's actually usable for ETL pipelines (most implement only type and required);
  • doesn't emit per-record error rows tagged with the original line number;
  • doesn't let you drop invalid records or keep them tagged, depending on the use case.

This Actor takes JSONL line-by-line, validates each line, and emits one dataset row per record. 1M-line inputs are realistic.

Supported schema features (draft-07 subset)

  • type — string or array of types
  • required — array of property names
  • properties — per-property schemas
  • additionalPropertiesfalse or a schema
  • items — single schema for array elements
  • enum, const
  • minimum, maximum, exclusiveMinimum, exclusiveMaximum
  • minLength, maxLength, pattern
  • minItems, maxItems, uniqueItems
  • minProperties, maxProperties

Not in the subset: $ref, oneOf/anyOf/allOf/not, definitions, conditional if/then/else, format. If you need those, normalize the schema first or use json-schema-validator (Batch 3) as a meta-check.

Input

fieldtyperequireddefaultdescription
jsonlInlinestringone of two""Raw JSONL/NDJSON text.
jsonlUrlstringone of two""Public URL that returns JSONL/NDJSON.
schemaInlinestringone of two""JSON Schema (draft-07 subset).
schemaUrlstringone of two""Public URL that returns a JSON Schema document.
dropInvalidboolnofalseIf true, invalid records are dropped (replaced with {_kind:"dropped"}).
maxErrorsintno100Cap error list per record.
skipEmptyLinesboolnotrueSkip empty / whitespace-only lines.

Output

Per input line (one dataset item):

{ "_kind": "valid", "lineNumber": 1, "record": { "id": 1, "name": "Alice" } }
{ "_kind": "invalid", "lineNumber": 2, "valid": false, "record": {...}, "errorCount": 1, "errors": [{"path":"/id","code":"type","message":"expected type integer, got string"}] }
{ "_kind": "parse_error", "lineNumber": 3, "error": "...", "raw": "{...}" }

Plus a SUMMARY key:

{
"totalLines": 5,
"parsed": 4,
"parseErrors": 0,
"schemaValid": 2,
"schemaInvalid": 2,
"skippedEmpty": 1,
"byErrorCode": { "type": 2 }
}

Quick start

{
"jsonlInline": "{\"id\":1,\"name\":\"Alice\"}\n{\"id\":\"two\",\"name\":\"Bob\"}\n",
"schemaInline": "{\"type\":\"object\",\"required\":[\"id\",\"name\"],\"properties\":{\"id\":{\"type\":\"integer\"},\"name\":{\"type\":\"string\"}}}"
}

Pricing

Pay per event. Each line processed counts as 1 event (regardless of valid/invalid).

Local development

npm install
npm test
apify validate-schema
apify run --input-file=./example.json

License

MIT