Skip to content
pubscout

json_schema

5.2.2, released a year ago by workiva.com

Validate JSON data against JSON Schema drafts in Dart.

WASM-ready
$ flutter pub add json_schema
Source repository

What it does

Provides a Dart library to parse JSON Schemas and validate JSON instances. Supports synchronous and asynchronous schema creation, remote $ref fetching, and multiple Draft versions.

AI-written summary of version 5.2.2, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need runtime validation of JSON against a schema
  • You work with APIs that provide JSON Schema definitions
  • You require platform‑agnostic validation (web, Flutter, VM)

Skip it when

  • You only need simple type checks (use built‑in Dart checks)
  • You prefer code‑generated models over runtime validation

Strengths

  • Supports Draft 7, 2019‑09, 2020‑12
  • Asynchronous $ref resolution and URL/file loading
  • No code generation required

Weaknesses

  • Adds runtime overhead for validation
  • Limited to validation – no schema‑based code generation

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
5
import 'package:json_schema/json_schema.dart';

void main() {
  final schema = JsonSchema.create({"type": "integer"});
  print(schema.validate(3)); // true
  print(schema.validate(3.14)); // false
}

Alternatives

Packages that do the same job and could replace json_schema.

  • json_schema_builder

    Build and validate JSON Schemas in Dart with a fluent, type‑safe API

  • swagger_to_dart

    Generates freezed models and retrofit API clients from OpenAPI 3.x, Swagger 2.0, Postman collections and JSON Schema, in JSON or YAML.

  • deep_pick

    Type-safe API for manual JSON parsing with useful error messages.

  • hooks

    Dart API for the JSON-based protocol for package build and link hooks.

Works with

Packages commonly used together with json_schema: ones it builds on, ones built on it, and its own family.