Zema Logo

Validate untrusted data in Dart and Flutter. One schema, every boundary.

Describe the data you expect once. Zema checks API responses, form input, Firestore documents and local storage against it, reports every problem with its path and a translated message, and hands you clean, typed values. Pure Dart, works on mobile, desktop, web and server. No code generation.

From fromJson crashes to useful errors

User.fromJson(json) throws a TypeError on the first unexpected field, far from where the data came in, with nothing to show the user. A Zema schema reports everything at once:
final signUp = z.object({
  'email': z.string().email(),
  'password': z.string().min(8),
  'age': z.integer().gte(18).optional(),
});

final result = signUp.safeParse({'email': 'ada@', 'password': '123'});

for (final issue in result.errors) {
  print('${issue.pathString}: ${issue.message}');
}
// email: Invalid email format
// password: Must be at least 8 characters

Built for the places where Dart apps break

    API responses
    Validate JSON before it reaches your models. Get typed values with z.objectAs and an extension type, or pass the clean map to your Freezed / json_serializable fromJson.
    Flutter forms
    zema_forms drives text fields from the same schema: errors after blur, per-field rebuilds, focus on the first invalid field, coercion for numeric inputs.
    Firestore
    zema_firestore plugs into withConverter: every document read is validated, with Timestamp, GeoPoint and DocumentReference schemas. Supports cloud_firestore 5 to 7.
    Local storage
    zema_hive validates Hive CE writes and reads, and migrates documents written by older app versions on read. No TypeAdapters, no code generation.
    Messages for humans
    Each issue carries a code, a path such as items.[2].email and a translated message. English and French built in, add any locale, override any message.
    Feels like Zod
    z.object, safeParse, refine, transform, pipe, discriminated unions, coercion. If you know Zod from TypeScript, you already know Zema.

Why not just Freezed or json_serializable?

They generate models; they do not check values. email is a String, not a valid email. age is an int, not "18 or more". Zema covers that layer and composes with them, or replaces code generation entirely with extension types. Read the full comparison.
Copyright © 2026