Skip to content
pubscout

llm_json_stream

1.0.0, released 6 months ago by vincentsanicolas.me

A streaming JSON parser optimized for parsing LLM responses incrementally.

WASM-ready
$ flutter pub add llm_json_stream
Source repository

What it does

Parses JSON character-by-character as it streams in from LLM responses. Allows path-based subscriptions to properties so you can receive values chunk-by-chunk or await complete values without waiting for the entire response to finish.

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

Use it when

  • You need to display streaming LLM text responses or JSON data in real-time.
  • You want to avoid UI jumps by populating lists and maps progressively as they begin parsing.

Skip it when

  • You are parsing standard static JSON files where traditional jsonDecode() is sufficient.

Strengths

  • Processes incomplete JSON fragments chunk-by-chunk without throwing errors.
  • Provides both streams (for live typing effects) and futures (for atomic values) on every property.
  • Includes robust handling for escape sequences, unicode, and large arrays.

Weaknesses

  • Adds overhead compared to built-in JSON decoding if streaming is not required.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
1
final parser = JsonStreamParser(llmResponseStream);
parser.getStringProperty('message').stream.listen((chunk) {
  displayText += chunk;
});

Alternatives

Packages that do the same job and could replace llm_json_stream.