NDJSON Streaming
NDJSON, or newline-delimited JSON, is a format where each line contains one complete JSON object. It allows APIs to stream large result sets incrementally, so clients can parse and display records as they arrive instead of waiting for one large JSON array to finish downloading.
Technical Architecture & Deep-Dive
A standard JSON array must be fully received before most parsers can return it. NDJSON avoids this: each line is independently valid, so streaming parsers emit records immediately.
NDJSON is common in log exports, bulk APIs, and AI responses. Edge runtimes support streaming bodies, so a gateway can transform or filter each line as it passes through without buffering the entire payload in memory.
Key Architectural Benefits
Implement NDJSON Streaming at the Edge
Deploy lightweight API aggregation, edge caching, and secret injection in minutes without Docker containers or complex servers.
Frequently Asked Questions
Q:How is NDJSON different from server-sent events?
NDJSON is a data format of one JSON object per line. Server-sent events is a browser protocol with event framing, reconnection, and an EventSource API.
Related Architecture Concepts
Server-Sent Events (SSE) is a web standard that lets a server push a continuous stream of text events to a client over a single long-lived HTTP connection. Browsers consume SSE with the EventSource API, and it is widely used to stream AI model tokens and live updates.
API bandwidth optimization is reducing the amount of data transferred between APIs and clients. Techniques include removing unused fields, compressing responses, caching close to users, using conditional requests, and aggregating calls to avoid redundant transfers.
Payload Slimming is the technique of stripping unneeded properties, internal metadata, and verbose JSON fields from API responses at the edge before sending them to the client. This reduces response size by 80% to 95%, cutting mobile bandwidth usage, memory overhead, and JSON parsing time.