llm_json_stream
1.0.0, released 6 months ago by vincentsanicolas.me
A streaming JSON parser optimized for parsing LLM responses incrementally.
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.
- openai_dart
Dart and Flutter client for OpenAI REST APIs and realtime WebSocket/WebRTC workflows.
91Compare - anthropic_sdk_dart
Dart client for the Anthropic API with streaming and tool support
86Compare - colorist_ui
A Flutter library of UI components for an LLM codelab.
69Compare - ollama
A Dart client for interacting with the Ollama API.
39Compare