Skip to content
pubscout

json_repair_flutter

2.0.2, released a year ago by onecrest.io

Repairs malformed JSON strings such as those returned by LLMs or unstable APIs

WASM-ready
$ flutter pub add json_repair_flutter
Source repository

What it does

A stateful parser that reads broken JSON strings and fixes common errors like trailing commas, unquoted keys, single quotes, comments, and missing brackets. It returns a decoded Dart object directly.

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

Use it when

  • Parsing untrusted or malformed JSON from LLM outputs
  • Handling slightly invalid JSON returned by third-party APIs or user input
  • Extracting valid JSON embedded within surrounding text

Skip it when

  • Working with strict JSON data that is guaranteed to be valid and error-free
  • Needing static code generation for type-safe models

Strengths

  • Forgiving parser handles missing braces, commas, quotes, and comments
  • Extracts JSON objects from surrounding conversational text
  • Provides optional diagnostic logging for repair actions

Weaknesses

  • Reparing heavily corrupted data can occasionally result in unexpected structure
  • Not a replacement for proper schema validation

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
1
import 'package:json_repair_flutter/json_repair_flutter.dart';

void main() {
  const malformedJson = "{name: 'John Doe', age: 30,}";
  final decodedData = repairJson(malformedJson);
  print(decodedData);
}

Alternatives

Packages that do the same job and could replace json_repair_flutter.