📡

Server-Sent Events (SSE) Formatter — Build and Debug Real-Time Streams

Build Server-Sent Events messages with id, event, data, retry, and comment fields for testing SSE endpoints. Fill in each field individually and instantly see the correctly formatted SSE message string with double-newline terminator. Supports multi-line data fields, keep-alive comment lines, and an escaped wire-format view. Five presets cover the most common SSE patterns. Free and runs entirely in your browser.

API ToolsAPI & Backend
Loading tool...

How to Use Server-Sent Events (SSE) Formatter — Build and Debug Real-Time Streams

How to Use the SSE Event Formatter:

  1. Load a Preset (Optional): Click any preset button at the top to pre-fill all fields with a real-world SSE pattern. Simple loads a plain data-only event. Named Event shows a typed JSON event with an id. Multi-line demonstrates streaming chunks as separate data fields. With Retry sets a custom reconnection delay. Heartbeat shows a keep-alive comment-only message. Each preset can be edited after loading.

  2. Enter a Comment (Optional): The comment field renders as a line starting with : (colon-space). Per the SSE specification, comment lines are completely ignored by the browser's EventSource client and are used to keep the connection alive during idle periods. Type any text — "ping", "keep-alive", or server metadata — and it will appear as : your text in the formatted output.

  3. Enter an Event ID (Optional): The id field sets the event identifier. The browser stores this value and sends it as a Last-Event-ID header on reconnection, allowing the server to resume the stream from the correct position after a disconnect. Use sequential integers, UUIDs, or timestamps as appropriate for your stream design.

  4. Enter an Event Type (Optional): The event field sets the event type name. If omitted, the browser dispatches the event as a generic "message" event and your addEventListener("message", handler) will receive it. If set, use a named event listener — addEventListener("update", handler) for event: update. Event type names should not contain whitespace.

  5. Enter the Data Payload: The data textarea is the main content of the event. For JSON payloads, paste the serialised JSON on a single line. For multi-line streaming responses, press Enter to add a new line — each line in the textarea becomes a separate data: field in the formatted output. The browser concatenates multiple data fields with a newline when constructing the event data property.

  6. Enter a Retry Value (Optional): The retry field tells the browser how many milliseconds to wait before attempting to reconnect after the stream drops. Enter a non-negative integer only — decimals and negative values are not valid per the SSE specification. A common value is 3000 (3 seconds). If omitted, the browser uses its default reconnection interval (typically a few seconds).

  7. Read the Stats Row: Three metrics update instantly above the output: Fields (number of active SSE fields in the message), Data lines (how many data: lines were generated from the data textarea), and Bytes (the total byte size of the formatted message including the terminating blank line).

  8. Switch Between Formatted and Escaped Views: The Formatted view shows the message exactly as it would appear on the wire, with real line breaks and a trailing blank line. The Escaped view shows the literal \n characters — useful for constructing the string in code (e.g., when writing a Python/Node.js SSE endpoint that builds the response string manually).

  9. Copy the Message: Click Copy to copy the formatted SSE message string (with actual newlines) to your clipboard. Use it in curl to test an SSE endpoint, in Postman's response body, or directly in server-side code. The copied text always includes the double-newline terminator required by the SSE specification.

  10. Test Your Endpoint: Paste the formatted message into a tool like curl or Postman to simulate an SSE response. A valid SSE response requires Content-Type: text/event-stream and Transfer-Encoding: chunked or HTTP/2 streaming. Each event in the stream must end with a blank line (\n\n).

Common Use Cases:

  • SSE endpoint development: Format test events to verify your EventSource client parses id, event, data, and retry fields correctly before integrating with a live stream.
  • Streaming LLM responses: Build multi-line data messages that simulate chunked text from an AI model to test your frontend streaming UI.
  • Real-time notification systems: Construct named events (event: notification) with JSON payloads to test browser-side event listeners.
  • Keep-alive debugging: Generate heartbeat comment messages (: ping) to verify that your SSE middleware does not drop idle connections.
  • Reconnection testing: Set a retry field to test that your client respects the server-specified reconnection delay rather than using the browser default.
  • SSE proxy testing: Format edge-case messages (empty data, multi-line data, missing fields) to verify your SSE proxy or middleware handles all valid SSE shapes correctly.
  • Documentation and spec verification: Use the escaped view to confirm the exact byte sequence of a message when writing SSE protocol documentation.

Tips and Best Practices:

  • Every valid SSE message must end with a blank line (\n\n). The formatter adds this automatically — do not add it manually in the data field.
  • JSON payloads must be on a single line when used as SSE data. Newlines inside JSON would create multiple data: fields, and the browser would concatenate them with \n, producing broken JSON.
  • Use the Multi-line preset to see how streaming token-by-token responses work — each token on a new textarea line becomes a separate data: field.
  • The id field is optional but strongly recommended for any stream that clients may reconnect to. Without it, the browser cannot resume the stream after a network drop.
  • Comments (: lines) are useful for keep-alive pings but generate zero data on the client side. Do not rely on them to carry information.
  • The retry value is a hint to the browser, not a guarantee — some browsers cap the minimum reconnection delay regardless of the retry field.
  • Use named events (event: type) to fan out different event types over a single SSE connection, with separate addEventListener calls on the client.
  • Switch to the Escaped view when writing server code to see the exact string your endpoint must produce: fields joined by \n and terminated by \n\n.

Frequently Asked Questions

Most Viewed Tools

📺

Screen Size Converter — Diagonal Dimension Tool

7,183 views

Calculate screen width and height from diagonal size and aspect ratio. Convert between inches and centimeters for displays, TVs, and monitors with instant dimension calculations.

Use Tool →
🖨️

DPI Calculator — Print Resolution Tool

5,447 views

Calculate DPI (dots per inch), image dimensions, and print sizes. Convert between pixels and physical dimensions for printing and displays.

Use Tool →
🔐

TOTP Code Generator — 2FA Testing Tool

3,864 views

Generate time-based one-time passwords from a TOTP secret key. Enter your base32 secret, choose a period and digit length, and get the current and next codes with a live countdown timer. Useful for testing and debugging 2FA integrations.

Use Tool →
🔑

Password Entropy Calculator — Crack Time Estimator

3,786 views

Calculate the information-theoretic bit entropy of any password or API key. Detects character set pools automatically, shows the total number of possible combinations, and estimates crack time across five attack scenarios from rate-limited web logins to GPU cracking clusters.

Use Tool →
{}

JSONL Formatter — Line-by-Line Validator

3,760 views

Format, validate, and inspect JSON Lines (JSONL) and NDJSON files. Validates each line individually, reports parse errors by line number, outputs compact JSONL or a pretty-print preview, and lets you download the cleaned file.

Use Tool →
{ }

JSON to Zod — Schema Generator

3,624 views

Generate Zod validation schema code from a JSON sample object. Infers z.string(), z.number(), z.boolean(), z.array(), z.object(), and z.null() types automatically. Handles nested objects, arrays of objects with optional field detection, and outputs copy-ready TypeScript with import and z.infer type alias.

Use Tool →
⏱️

Seconds to Time Converter — HH:MM:SS Formatter

3,499 views

Convert seconds to HH:MM:SS time format instantly with precise calculations and easy-to-read formatting.

Use Tool →
🔐

TLS Cipher Suite Checker — Strength Analyzer

3,488 views

Check TLS protocol version compatibility and cipher suite strength ratings against current best practices. Supports IANA and OpenSSL cipher names — rates each suite as Strong, Weak, or Deprecated and explains why.

Use Tool →

Related API & Backend Tools

🔁

Webhook Retry Config Calculator — Simulate Exponential Backoff & Jitter

Configure exponential backoff parameters and preview the full retry schedule for webhook delivery. Enter max attempts, initial delay, multiplier, jitter, and a max delay cap to instantly see each retry timestamp, cumulative elapsed time, jitter range, and which delays hit the cap. Supports presets for standard, aggressive, conservative, Stripe-style, and fixed-interval retry policies. Free and runs entirely in your browser.

Use Tool →
{}

GraphQL Variables Formatter — Query Validator

Format and validate GraphQL query variables JSON for use in queries and API clients. Paste your variables JSON alongside a GraphQL query to instantly format the JSON, validate that each variable matches its declared type, catch missing required variables, and highlight undeclared extras.

Use Tool →
🗄️

API Mock Server Config Generator — Build Instant Mock Endpoints Online

Paste API route definitions to instantly generate JSON configuration files for json-server, Mockoon, and Prism mock servers. Define routes as METHOD /path lines and get ready-to-use config with realistic sample data.

Use Tool →
🔄

Postman to OpenAPI Converter — Spec Migration Tool

Convert Postman Collection v2.1 JSON to OpenAPI 3.0 specification format. Upload or paste your collection, and get a downloadable openapi.yaml or openapi.json with mapped paths, parameters, request bodies, and example responses.

Use Tool →

GraphQL Subscription Builder — Generate WebSocket Payloads and Client Queries

Build GraphQL subscription query strings and generate WebSocket connection code snippets for Apollo Client, urql, and graphql-ws. Define your operation name, variables, and selection fields visually, then copy the ready-to-use code.

Use Tool →
🔁

OpenAPI Mock Generator — Turn API Specs into Live Mock Servers

Paste an OpenAPI 3.x or Swagger 2.0 spec, select any endpoint, and instantly get a realistic mock request body and response matching the defined schemas. Also generates a ready-to-run cURL command.

Use Tool →
🔑

JWT Token Validator — Signature Verifier

Decode and validate JWT tokens instantly in your browser. Inspect header and payload claims, check expiry, and verify HMAC signatures (HS256/HS384/HS512). Free and private.

Use Tool →
📊

GraphQL Cost Estimator — Analyze Query Complexity and Depth

Assign custom field weights to a GraphQL schema and calculate the total query complexity score. Paste any GraphQL query, configure per-field costs, and get a per-field breakdown table showing depth, multipliers, and cumulative cost.

Use Tool →

Share Your Feedback

Help us improve this tool by sharing your experience

We will only use this to follow up on your feedback