Skip to content
pubscout

json_schema_builder

0.1.7, released 3 months ago by labs.flutter.dev

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

WASM-ready
$ flutter pub add json_schema_builder
Source repository

What it does

It lets you programmatically create JSON Schema 2020‑12 documents and validate data against them. The library handles schema references, remote fetching, and detailed error reporting.

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

Use it when

  • You need to validate structured data against a JSON Schema in a Dart/Flutter app
  • You want a standard‑compliant schema builder without writing raw JSON
  • You need synchronous validation for performance or offline use

Skip it when

  • You only need simple type checks and prefer built‑in Dart validation
  • You are already using a code‑generation approach for JSON models

Strengths

  • Full Draft 2020‑12 support
  • Fluent, type‑safe API
  • Synchronous validation path
  • Rich error reporting

Weaknesses

  • No code generation integration
  • Requires manual schema construction
  • Not a UI form builder

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
7

Add dependency via pubspec, import package, no build_runner needed

import 'package:json_schema_builder/json_schema_builder.dart';
final schema = S.object(properties:{'name':S.string()});
final errors = await schema.validate({'name':123});

Alternatives

Packages that do the same job and could replace json_schema_builder.

Works with

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