DevTools Logo

SSE Stream Tester & Generator

SSE Stream Tester & Generator

Validate a text/event-stream capture against the WHATWG parser, or generate a local stream and exercise an EventSource-like client — no server, no upload.

Runs in your browser
Try an example
Paste a capture or drop a .txt / .eventstream file — parsing happens as you type.

Captured event stream

0 lines · 0 bytes

CR, LF and CRLF all end lines; a blank line dispatches. Leading spaces after a colon are stripped once.

BOM absent · boundaries: LF 0 / CRLF 0 / CR 0

Parser report

Paste an SSE capture to validate it

Try an example above to see BOM handling, mixed line endings and spec warnings.

The validator strips a leading BOM, accepts CR, LF and CRLF line endings, joins multiple data: lines with a newline, applies id: and retry: exactly as the specification does, and flags undelivered events left in the buffer at end of stream. The generator renders a template on a local timer, feeds it through the same parser, and exposes an EventSource-like shim with onopen/onmessage/onerror, named listeners, readyState and lastEventId. Fault injection closes the simulated stream — the only event that legitimately triggers an error and reconnect — and the console shows the Last-Event-ID header a real client would resend. Everything runs in this tab; there is no server and no network request.

Worked examples

Validate a multi-line capture

event: update
data: first line
data: second line
id: 42

One event named update is dispatched with data "first line\nsecond line" and lastEventId 42. The blank line is the dispatch boundary.

Mixed line endings are legal

data: crlf

data: lf

data: cr
data: cr-2

CRLF, LF and CR boundaries are all accepted. The report records which style dispatched each event.

An invalid retry is ignored, not fatal

retry: abc
data: still delivered

retry must be a non-negative integer. An invalid value is ignored with a line-numbered warning and parsing continues; the event still dispatches.

Generate a ticker stream

event: tick
data: {"i":{{i}},"ts":"{{ts}}"}
id: {{i}}
retry: 1000

At 10 events per second the shim receives tick events with incrementing ids; pausing and resuming shows how lastEventId advances.

Examples

Multi-line data with a persistent id

Input
event: update
data: first line
data: second line
id: 42

Output
1 dispatched event · name update · data "first line\nsecond line" · id 42 · boundary LF

Two data lines are joined with a newline; id persists into later events until it is replaced.

Mixed CRLF, LF and CR boundaries

Input
data: crlf

data: lf

data: cr
data: cr-2

Output
3 events with boundaries CRLF, LF and CR respectively; the last event's data is "cr\ncr-2"

All three terminators are valid per the spec — mixing them does not reset buffers or invalidate the stream.

Invalid fields, valid stream

Input
retry: abc
data: still delivered
id: badid

Output
1 event with retry 0 and an empty id, plus line-numbered warnings for the ignored retry and NULL-containing id

Ignored fields never discard an event and never fire an error; only connection failure does that.

LLM token preset

Input
event: token
data: {"delta":"Hel"}

 … event: done
data: [DONE]

Output
Named token events in the shim console, followed by a done event carrying the [DONE] terminator

The preset mirrors common LLM streaming protocols so handler code can be tested without an API key or server.

About this tool

SSE Stream Tester is a browser-only workbench for the text/event-stream wire format. The Validator tab takes a captured stream — pasted from a curl dump, a HAR body or a log — and runs it through the WHATWG server-sent-events parsing algorithm: leading BOM removal, CR/LF/CRLF line handling, one optional leading space after a colon, blank-line dispatch, and the persistent id and retry buffers. The event table shows what a browser would actually dispatch, with a line-numbered warning for every field it ignores.

The Generator tab produces a synthetic stream on a local timer and feeds it through the very same parser, so client code can be exercised without a backend. A template supports {{i}}, {{ts}} and {{lastEventId}} placeholders, optional event/id/retry lines, a fault every N events, and an EventSource-like shim exposing onopen, onmessage, onerror, named addEventListener handlers, readyState, lastEventId and CONNECTING/OPEN/CLOSED constants. The console shows which handlers fired and what a reconnect would send in the Last-Event-ID header.

The two behaviors people most often get wrong are handled explicitly here. An id field containing NULL is ignored while the event still dispatches; a malformed retry line is ignored while parsing continues. Neither produces an error event — real SSE parsing has no line-level errors. The generator's fault injection therefore simulates a stream close, which is the condition that actually causes an EventSource to fire error and reconnect. Nothing is uploaded or persisted; the entire session lives in this tab.

What this tool does not do

  • Everything is local: no HTTP request is made, so CORS headers, real network failures, gzip behavior and genuine EventSource transport semantics cannot be tested here.
  • The client is an EventSource-like shim, not a native EventSource instance; it mirrors the parsing rules and public API used here but cannot reproduce browser connection management exactly.
  • Captures above 5 MB show a warning; parsing still completes but the table is capped at 5,000 rows and warnings at 200 entries. Use JSON export for the full result.
  • The generator's timer is subject to browser throttling in background tabs. It catches up in bursts using a monotonic counter and shows a throttled indicator, but exact wall-clock timing is not guaranteed.
  • Fault injection models a stream close, which is the only condition that legitimately fires an error and reconnect. Injecting malformed fields alone is silently ignored, exactly as a browser would do.
  • Nothing is uploaded, persisted or sent to a server; reloading the page clears the session.

How to use this tool

  1. Paste or drop a capture

    Switch to Validator and paste the raw text/event-stream body, or drop a .txt / .eventstream file into the input pane. HAR-extracted bodies work as pasted text.

  2. Read the event table

    Each row is an event a browser would dispatch: name, joined data, lastEventId, current retry and the CR/LF/CRLF style of its terminating blank line.

  3. Follow the warnings

    Warnings carry source line numbers. Click one to jump to that line in the textarea, or turn on Show bytes to see invisible BOM, CR, LF, tab and NULL characters.

  4. Generate a local stream

    Switch to Generator, pick a rate (1–50/s), an event count or infinite mode, and edit the template. Start the stream and watch the client console fill up.

  5. Exercise reconnect behavior

    Set Fault every to a positive N and reconnect delay in milliseconds. On the Nth event the shim sees a simulated stream close, fires onerror, then reconnects with the current Last-Event-ID.

  6. Export evidence

    Copy the validator report as Markdown, export the full parse as JSON, or copy/download the generated raw stream and console log.

Use cases

Debug an SSE endpoint

Paste a curl --no-buffer capture and see exactly which events the browser would dispatch, including boundary styles and ignored fields.

Test reconnect handling

Drive an EventSource-like client with incrementing ids, then close the simulated stream and verify the Last-Event-ID it would resend.

Review a vendor stream

Validate a captured third-party feed against the spec and export a JSON or Markdown report as QA evidence.

Prototype a streaming UI

Generate token events locally with the LLM preset while building a client that renders partial responses.

Teach the wire format

Show side by side how comments, multiple data lines, invalid retry values and truncated buffers are treated by the parser.

SSE fields and line endings

LineMeaning
data: valueAppends value to the event's data buffer. Multiple data lines are joined with a single LF when the event dispatches.
event: nameSets the event type for the current block. The last event line wins; with no event line the type is message.
id: valueSets the persistent lastEventId. A value containing NULL is ignored for that field; the event itself still dispatches.
retry: integerSets the reconnection time in milliseconds when the whole value is non-negative ASCII digits. Invalid values are ignored with a warning.
: commentA comment line, ignored by the parser. Useful as a keepalive; it never dispatches an event.
blank lineDispatches only if the data buffer is non-empty. CR, LF and CRLF are accepted as line terminators, including for the blank line.

A leading UTF-8 BOM is stripped before parsing. A stream that ends without a blank-line terminator leaves its buffered event undelivered — the report flags it rather than counting it as dispatched.

Common mistakes

Mistake:Thinking an id containing NULL drops the event.

Fix:Per the WHATWG algorithm only the id field is ignored; the event still dispatches with the previous lastEventId. The validator warns accordingly.

Mistake:Expecting invalid fields to fire onerror.

Fix:Line-level parse errors do not exist in SSE. Invalid retry values, unknown fields and malformed lines are ignored. Use the fault injection's stream-close mode to test error handling.

Mistake:Treating generator silence as a reconnect trigger.

Fix:A real EventSource reconnects only after the connection fails or closes. Pausing merely stops the local timer; the fault control simulates an actual close.

Mistake:Assuming every blank line dispatches an event.

Fix:A blank line with an empty data buffer dispatches nothing, so heartbeats and consecutive blank lines do not create phantom events.

Mistake:Writing 'data hello' instead of 'data: hello'.

Fix:The spec treats a colon-less line as a field name with an empty value, so the line is ignored. The validator flags it with its line number.

Mistake:Forgetting that an unterminated final event is discarded.

Fix:End each event with a blank line. The report marks buffered data at EOF as undelivered instead of counting it.

Frequently asked questions

How are multiple data: lines joined in SSE?

With a single newline character. Each data field appends its value plus LF to the data buffer; when a blank line dispatches the event, the parser removes the final LF and delivers the rest. So 'data: one' followed by 'data: two' and a blank line produces the payload "one\ntwo". An empty 'data:' line contributes an empty line to that join.

What happens to an invalid retry: field?

It is ignored and parsing continues. The value must consist entirely of non-negative ASCII digits to set the reconnection time in milliseconds; 'retry: abc' and 'retry: -1' are simply skipped with a line-numbered warning, and the event still dispatches. No error event is fired — SSE parsing has no line-level errors.

Does SSE reconnect automatically send Last-Event-ID?

Yes. A browser's EventSource keeps the last id field it saw in a non-empty id line and includes it as the Last-Event-ID request header on the next connection attempt after a failure. It also exposes that value as event.lastEventId. Reconnect timing comes from the retry field; silence alone does not trigger a reconnect. The generator's fault mode closes the simulated stream so you can watch the header value in the console.

What ends an SSE event — \n\n or \r\n\r\n?

Either one, plus a lone CR variant. The WHATWG parser accepts CR, LF and CRLF as line terminators, and an empty line in any of those styles dispatches the buffered event. Mixing styles within one stream is valid; this tool records the terminator used for each event in the Boundary column.

Can I test SSE without a server?

Yes. The Generator tab renders a template on a local timer, pushes the bytes through the same spec parser, and delivers the events to an EventSource-like shim. You can test named listeners, onmessage, error handling, lastEventId and reconnect values with no backend or network request. For true transport behavior — CORS, real disconnects, HTTP headers — you still need a real EventSource against a server.

Does an id field containing NULL discard the event?

No. The spec only ignores that id field; the event is still dispatched with whatever lastEventId was set previously. The validator reports this with a line-numbered warning rather than silently dropping the event or inventing a parse error.

Why does my final event not appear in the table?

Because the stream ended without a blank line. The parser buffers fields until it sees an empty line; at end of file an incomplete event is discarded, exactly as a browser does. The report flags it as undelivered with its starting line number — add a blank line after the last data field.

References & standards