什么是 SSE(Server-Sent Events)?
SSE(Server-Sent Events)是 HTTP 长连接的一种轻量级服务器推送协议,服务器通过 Content-Type: text/event-stream 持续向客户端发送事件流。每个事件由 event、data、id、retry 等字段组成,事件之间以空行分隔。
SSE 广泛应用于 AI 大模型的流式对话接口。大模型生成回复时,会将内容拆成多个 data 事件逐个推送(每个事件包含一小段 token),客户端逐步拼接得到完整回复。这种逐块推送的格式对人类阅读很不友好,原始文本分散、重复字段多、难以快速理解。
本工具的功能:
- 事件解析:按 SSE 协议规范将原始文本拆分为独立事件,每个事件显示 event/data/id/retry 字段
- JSON 自动格式化:当 data 内容为 JSON 时,自动美化并语法高亮(键名紫色、字符串绿色、数字蓝色、布尔橙色、null 灰色)
- 聚合完整消息:将所有 data 事件的内容拼接为一段完整文本,方便查看大模型的完整回复
- 统计信息:显示事件总数、事件类型、数据总长度
适用场景:调试 AI 大模型流式 API(OpenAI Chat Completions、Claude、Gemini 等)、查看 EventSource 响应内容、排查 SSE 连接问题。
What is SSE (Server-Sent Events)?
SSE (Server-Sent Events) is a lightweight server-push protocol over HTTP long-lived connections. The server sends a continuous event stream via Content-Type: text/event-stream. Each event consists of fields like event, data, id, and retry, separated by blank lines.
SSE is widely used in AI large model streaming APIs. When generating a response, the model splits content into multiple data events (each containing a small token chunk), which the client progressively assembles into the full reply. This chunked format is hard to read — the raw text is scattered, fields repeat, and it's difficult to quickly understand the content.
This tool provides:
- Event Parsing — Split raw text into individual SSE events per the protocol spec, showing event/data/id/retry fields for each
- JSON Auto-formatting — When data is JSON, auto-beautify with syntax highlighting (keys purple, strings green, numbers blue, booleans amber, null gray)
- Aggregated Message — Concatenate all data events into a single complete text, ideal for reading the full AI model reply
- Statistics — Show total event count, event types, and total data length
Use cases: Debug AI streaming APIs (OpenAI Chat Completions, Claude, Gemini, etc.), inspect EventSource responses, troubleshoot SSE connection issues.