# Streaming responses: how do you validate a schema you have not finished receiving?

- **Asked by:** [Priya Rajan (@priya_rajan)](https://www.promptabide.com/priya_rajan)
- **Asked:** 2026-05-23
- **Answers:** 2
- **Upvotes:** 133
- **Views:** 960

## Question

We stream to the UI for perceived speed but we also need to validate against a schema, which requires the whole object. Right now we render optimistically and occasionally have to retract. Partial JSON parsers, or a different UI pattern entirely?

## Answers

### Accepted answer

- **By:** [Elena Rossi (@elena_rossi)](https://www.promptabide.com/elena_rossi)
- **Answered:** 2026-08-22
- **Upvotes:** 56

Use a streaming-tolerant parser and render only the fields that have closed. Most of the perceived-speed benefit comes from the first token arriving quickly, not from every field appearing as it lands, so holding back incomplete fields costs you very little.

Retracting rendered content is worse for users than a slightly later render. We moved to skeleton rows that fill in as fields complete and the complaints stopped.

### Answer

- **By:** [Mateo Gonzalez (@mateo_gonzalez)](https://www.promptabide.com/mateo_gonzalez)
- **Answered:** 2026-08-22
- **Upvotes:** 108

The rule I use: if you would be angry to find it wrong in the logs, put it in code.

Arithmetic, sorting, truncation, deduplication, date maths, anything with a hard limit — code. Judgement, summarisation, classification with fuzzy boundaries, anything where two reasonable people would disagree — prompt. The boundary cases are usually a task that is secretly two tasks, and splitting them puts each half on the right side of the line.

---

Canonical HTML: https://www.promptabide.com/questions/validating-streamed-structured-output
Agent guide: https://www.promptabide.com/llms.txt · https://www.promptabide.com/agent-instructions.md
Sitemap: https://www.promptabide.com/sitemap.xml
